-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getting "This socket is already used by another greenlet" #709
Comments
@dribler How you are using kafka-python with gevent ? |
We don't actually use greenlets explicitly. Our producer is a web app and we use uwsgi to run it: uwsgi --socket=0.0.0.0:9000 --wsgi-file app.py --loop gevent --master --gevent 250 .... In app.py we just do at first line from gevent.monkey import patch_all; patch_all() We use single KafkaProducer instance per uwsgi worker. I was able to reproduce same issue with following: from gevent.monkey import patch_all
patch_all()
from gevent import spawn, sleep
from kafka import KafkaProducer
import time
producer = KafkaProducer(....)
def produce():
time.sleep(5) # didn't look deep into this, but doesn't work w/o it
for i in range(1000):
producer.send('test', str(i) * 1024)
print('finished')
g1 = spawn(produce)
g2 = spawn(produce)
g1.join(), g2.join() As quick fix for me worked simple threading.Lock. So actually i have temporary solution. def wakeup(self):
with self._wakeup_lock:
if self._wake_w.send(b'x') != 1:
log.warning('Unable to send to wakeup socket!') |
We also got exception like following. kafka-python 0.9.5.
|
Bugs in 0.9.5 will not be fixed. Please upgrade to latest (1.2.5)
|
Hi,
I know you are not testing kafka-python with gevent, anyway it seems work quite good with gevent.
We currently experiencing only one issue with it. From time to time we getting following exception:
Could you please look into this? Probably some thread lock could solve it?
Thanks!
The text was updated successfully, but these errors were encountered: