Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
fail_slp_switch.py30 linesDownload Raw Back to tests
1# -*- coding: utf-8 -*-
2"""
3A test helper for seeing what happens when slp_switch()
4fails.
5"""
6# pragma: no cover
7
8import greenlet
9
10
11print('fail_slp_switch is running', flush=True)
12
13runs = []
14def func():
15    runs.append(1)
16    greenlet.getcurrent().parent.switch()
17    runs.append(2)
18    greenlet.getcurrent().parent.switch()
19    runs.append(3)
20
21g = greenlet._greenlet.UnswitchableGreenlet(func)
22g.switch()
23assert runs == [1]
24g.switch()
25assert runs == [1, 2]
26g.force_slp_switch_error = True
27
28# This should crash.
29g.switch()
30 
codekingpro/portable-devtools · Team Ai