dhq
dhq

Reputation: 31

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

i user zerorpc to build my rpc program, but i found an interest phenomenon,

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(), i had try so many time, the number 1,000 is fixed, but i do not know why? **

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

Upvotes: 0

Views: 233

Answers (0)

Related Questions