You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromgeventimportmonkey; monkey.patch_all()
importtimefromcollectionsimportdequeimportgeventdeffunc():
whileTrue:
print('{:.3f} {} iteration'.format(time.time(), id(gevent.getcurrent())))
gevent.sleep(0.5)
classCustomGreenlet(gevent.Greenlet):
def__init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.switch_log=deque(maxlen=100)
defswitch(self, *args, **kwargs):
print('{:.3f} {} switch in'.format(time.time(), id(gevent.getcurrent())))
self.switch_log.append(0)
returnsuper().switch(*args, **kwargs)
defswitch_out(self):
print('{:.3f} {} switch out'.format(time.time(), id(gevent.getcurrent())))
assertself.switch_log, 'Switch out without switch in is detected'assertself.switch_log[-1] ==0, 'Switch out without switch in is detected'self.switch_log.append(1)
greenlets= [CustomGreenlet(func) for_inrange(100)]
forgreenletingreenlets:
greenlet.start()
gevent.joinall(greenlets)
But in a real world applications that involve actual IO and a lot of other stuff I got assert self.switch_log[-1] == 0, 'Switch out without switch in is detected' fired.
2019-01-13 16:06:26,455 ERROR gid:48 ERROR during iteration (in 0.000431776s): TaskResultsConsumer
Traceback (most recent call last):
File "/home/dmugtasimov/gitrep/packy/packy-agent/packy_agent/worker/loops/base/loop.py", line 38, in iteration_wrapper
self.iteration()
File "/home/dmugtasimov/gitrep/packy/packy-agent/packy_agent/worker/loops/base/consumer.py", line 27, in iteration
item = self.inbound_queue.get(timeout=self.timeout)
File "src/gevent/queue.py", line 329, in gevent._queue.Queue.get
File "src/gevent/queue.py", line 344, in gevent._queue.Queue.get
File "src/gevent/queue.py", line 321, in gevent._queue.Queue.__get_or_peek
File "src/gevent/_waiter.py", line 151, in gevent.__waiter.Waiter.get
File "src/gevent/_greenlet_primitives.py", line 60, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
File "src/gevent/_greenlet_primitives.py", line 60, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
File "src/gevent/_greenlet_primitives.py", line 63, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
File "/home/dmugtasimov/gitrep/packy/packy-agent/packy_agent/utils/gevent.py", line 34, in switch_out
assert self.switch_log[-1][0] == SwitchType.IN, 'Switch out without switch in is detected'
AssertionError: Switch out without switch in is detected
How should I approach to debug this? Is it a bug or feature? Should I ignore consecutive switch_out() calls to the same Greenlet? If so, then which ones?
The text was updated successfully, but these errors were encountered:
In a simple setup like this all works fine:
But in a real world applications that involve actual IO and a lot of other stuff I got
assert self.switch_log[-1] == 0, 'Switch out without switch in is detected'
fired.How should I approach to debug this? Is it a bug or feature? Should I ignore consecutive
switch_out()
calls to the same Greenlet? If so, then which ones?The text was updated successfully, but these errors were encountered: