psycopg / psycogreen

Integration of psycopg2 with coroutine libraries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why I'm getting this error "gevent.exceptions.InvalidSwitchError: Invalid switch into"

pjain05 opened this issue · comments

Hello,

I'm seeing the below error trace in my application logs due to which server is not responding and APIs are getting 500 ISE error.

Sqlachemy = 2.0
Gevent= 22.10.0
psycogreen =1.0.2
psycopg2=2.9.5
grrenlet=2.0.1

File "/usr/local/lib/python3.9/site-packages/psycogreen/gevent.py", line 36, in gevent_wait_callback
    wait_read(conn.fileno(), timeout=timeout)
  File "src/gevent/_hub_primitives.py", line 353, in gevent._gevent_c_hub_primitives.wait_read
  File "src/gevent/_hub_primitives.py", line 367, in gevent._gevent_c_hub_primitives.wait_read
  File "src/gevent/_hub_primitives.py", line 350, in gevent._gevent_c_hub_primitives.wait_on_watcher
  File "src/gevent/_hub_primitives.py", line 304, in gevent._gevent_c_hub_primitives._primitive_wait
  File "src/gevent/_hub_primitives.py", line 46, in gevent._gevent_c_hub_primitives.WaitOperationsGreenlet.wait
  File "src/gevent/_hub_primitives.py", line 46, in gevent._gevent_c_hub_primitives.WaitOperationsGreenlet.wait
  File "src/gevent/_hub_primitives.py", line 57, in gevent._gevent_c_hub_primitives.WaitOperationsGreenlet.wait
gevent.exceptions.InvalidSwitchError: Invalid switch into <Greenlet at 0x7f8e26b51c20: _handle_and_close_when_done(functools.partial(<bound method GeventWorker.handl, <bound method StreamServer.do_close of <StreamServ, (<gevent._socket3.socket at 0x7f8e269fc3a0 object,)>: got None (expected <gevent._gevent_c_waiter.Waiter object at 0x7f8e26a379f0>; waiting on <Hub '' at 0x7f8e2b765810 epoll default pending=0 ref=15 fileno=6 resolver=<gevent.resolver.thread.Resolver at 0x7f8e2872d1f0 pool=<ThreadPool at 0x7f8e287aa190 tasks=0 size=0 maxsize=10 hub=<Hub at 0x7f8e2b765810 thread_ident=0x7f8e2d59bb48>>> threadpool=<ThreadPool at 0x7f8e287aa190 tasks=0 size=0 maxsize=10 hub=<Hub at 0x7f8e2b765810 thread_ident=0x7f8e2d59bb48>> thread_ident=0x7f8e2d59bb48> with <io at 0x7f8e26b4de40 native=0x7f8e26b4de80 fd=25 events=READ active callback=<bound method Waiter.switch of <gevent._gevent_c_waiter.Waiter object at 0x7f8e26a379f0>> args=(<gevent._gevent_c_waiter.Waiter object at 0x7f8e26a379f0>,)>)

You should hear from gevent about this.