Skip to content
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

zerorpc client will stuck after calling an Not exist server timeout for more 1,000 times #236

Open
ddhq opened this issue Jan 9, 2021 · 1 comment
Labels

Comments

@ddhq
Copy link

ddhq commented Jan 9, 2021

code

import zerorpc

c = zerorpc.Client(timeout=0.1)
c.connect("tcp://192.168.33.12:4242")

count = 0
while True:
    print(count)
    try:
        print c.hello("RPC", async=False)
    except zerorpc.exceptions.TimeoutExpired as e:
        print(e)
    count+=1

the server above is not reachable, it will kept print timeout message, but over 1,000 times, it stuck in gevent.queue.Channel.put()

output

992
timeout after 1s, when calling remote method hello
993
timeout after 1s, when calling remote method hello
994
timeout after 1s, when calling remote method hello
995
timeout after 1s, when calling remote method hello
996
timeout after 1s, when calling remote method hello
997
timeout after 1s, when calling remote method hello
998
timeout after 1s, when calling remote method hello
999
timeout after 1s, when calling remote method hello
1000
timeout after 1s, when calling remote method hello
1001



^CKeyboardInterrupt
2021-01-09T06:12:34Z
Traceback (most recent call last):
  File "hello_client.py", line 12, in <module>
    print c.hello("RPC", async=False)
  File "/usr/lib/python2.7/site-packages/zerorpc/core.py", line 283, in <lambda>
    return lambda *args, **kargs: self(method, *args, **kargs)
  File "/usr/lib/python2.7/site-packages/zerorpc/core.py", line 272, in __call__
    bufchan.emit_event(request_event)
  File "/usr/lib/python2.7/site-packages/zerorpc/channel.py", line 234, in emit_event
    self._channel.emit_event(event)
  File "/usr/lib/python2.7/site-packages/zerorpc/heartbeat.py", line 116, in emit_event
    self._channel.emit_event(event, timeout)
  File "/usr/lib/python2.7/site-packages/zerorpc/channel.py", line 154, in emit_event
    self._multiplexer.emit_event(event, timeout)
  File "/usr/lib/python2.7/site-packages/zerorpc/channel.py", line 66, in emit_event
    return self._events.emit_event(event, timeout)
  File "/usr/lib/python2.7/site-packages/zerorpc/events.py", line 360, in emit_event
    self._send(parts, timeout)
  File "/usr/lib/python2.7/site-packages/zerorpc/events.py", line 136, in __call__
    self._send_queue.put(parts, timeout=timeout)
  File "src/gevent/queue.py", line 629, in gevent._queue.Channel.put
  File "src/gevent/queue.py", line 624, in gevent._queue.Channel.put
  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 64, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/__greenlet_primitives.pxd", line 35, in gevent.__greenlet_primitives._greenlet_switch
KeyboardInterrupt

any help will appreciated

@bombela
Copy link
Member

bombela commented Mar 24, 2023

This is because the zmq queue is full after 1000 entries. It is a really annoying side effect of zmq. I don't think there is any way out of this sadly. Besides replacing zmq. Or maybe newer version of zmq have a way to clear the queue.

@bombela bombela added the bug label Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants