geventactor: Exception KeyError ()
WayneYe opened this issue · comments
I simply replace ThreadingActor with GeventActor in the official examples/plain_actor.py, the code is below:
#! /usr/bin/env python
import pykka
import gevent
import gevent.monkey
from pykka.gevent import GeventActor
gevent.monkey.patch_all()
#class PlainActor(pykka.ThreadingActor):
class PlainActor(GeventActor):
def __init__(self):
super(PlainActor, self).__init__()
self.stored_messages = []
def on_receive(self, message):
if message.get('command') == 'get_messages':
return self.stored_messages
else:
self.stored_messages.append(message)
if __name__ == '__main__':
actor = PlainActor.start()
actor.tell({'no': 'Norway', 'se': 'Sweden'})
actor.tell({'a': 3, 'b': 4, 'c': 5})
print(actor.ask({'command': 'get_messages'}))
actor.stop()
After run this I saw:
Exception KeyError: KeyError(4536872784,) in <module 'threading' from '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.pyc'> ignored
My environments:
python 2.7.10
pykka 1.2.1
gevent 1.0.2
I can reproduce this using:
- Python 2.7.15
- Pykka 1.2.1
- Gevent 1.0.2
gevent.monkey.patch_all()
If I do either of the following, the problem disappears:
- Skip the monkey patching
- Upgrade Gevent from 1.0.2 to 1.1.0 or newer
Thus, I believe this to be a bug in Gevent 1.0.x that was fixed in Gevent 1.1.0 or one of its prereleases, released almost three years ago.
Sorry for not looking into this sooner.