error: cannot switch to a different thread

1,068 views
Skip to first unread message

Alvin Ang

unread,
Jul 22, 2018, 2:51:00 PM7/22/18
to web2py-users
Deployed web2py to production lately, keep getting an intermittent error "error: cannot switch to a different thread". Please help.
  • CentOS Linux release 7.4.1708
  • web2py Version 2.16.1-stable+timestamp.2017.11.14.05.54.25
  • Apache Version 2.4.33
  • MySQL Version 10.1.30-MariaDB
  • Python Version 2.7.15
Traceback (most recent call last):
  File "/home/wesl/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "/home/wesl/web2py/applications/wesl/controllers/default.py", line 290, in <module>
  File "/home/wesl/web2py/gluon/globals.py", line 419, in <lambda>
    self._caller = lambda f: f()
  File "/home/wesl/web2py/applications/wesl/controllers/default.py", line 50, in index
    row = db(db.team).select()
  File "/home/wesl/web2py/gluon/packages/dal/pydal/objects.py", line 2250, in select
    return adapter.select(self.query, fields, attributes)
  File "/home/wesl/web2py/gluon/packages/dal/pydal/adapters/base.py", line 762, in select
    return self._select_aux(sql, fields, attributes, colnames)
  File "/home/wesl/web2py/gluon/packages/dal/pydal/adapters/base.py", line 718, in _select_aux
    rows = self._select_aux_execute(sql)
  File "/home/wesl/web2py/gluon/packages/dal/pydal/adapters/base.py", line 712, in _select_aux_execute
    self.execute(sql)
  File "/home/wesl/web2py/gluon/packages/dal/pydal/adapters/__init__.py", line 67, in wrap
    return f(*args, **kwargs)
  File "/home/wesl/web2py/gluon/packages/dal/pydal/adapters/base.py", line 412, in execute
    rv = self.cursor.execute(command, *args[1:], **kwargs)
  File "/home/wesl/web2py/gluon/contrib/pymysql/cursors.py", line 166, in execute
    result = self._query(query)
  File "/home/wesl/web2py/gluon/contrib/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "/home/wesl/web2py/gluon/contrib/pymysql/connections.py", line 835, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/wesl/web2py/gluon/contrib/pymysql/connections.py", line 1019, in _read_query_result
    result.read()
  File "/home/wesl/web2py/gluon/contrib/pymysql/connections.py", line 1302, in read
    first_packet = self.connection._read_packet()
  File "/home/wesl/web2py/gluon/contrib/pymysql/connections.py", line 961, in _read_packet
    packet_header = self._read_bytes(4)
  File "/home/wesl/web2py/gluon/contrib/pymysql/connections.py", line 988, in _read_bytes
    data = self._rfile.read(num_bytes)
  File "/home/wesl/web2py/gluon/contrib/pymysql/_socketio.py", line 59, in readinto
    return self._sock.recv_into(b)
  File "/home/wesl/lib/python2.7/site-packages/gevent/_socket2.py", line 330, in recv_into
    self._wait(self._read_event)
  File "src/gevent/_hub_primitives.py", line 265, in gevent.__hub_primitives.wait_on_socket
  File "src/gevent/_hub_primitives.py", line 266, in gevent.__hub_primitives.wait_on_socket
  File "src/gevent/_hub_primitives.py", line 252, in gevent.__hub_primitives._primitive_wait
  File "src/gevent/_hub_primitives.py", line 46, in gevent.__hub_primitives.WaitOperationsGreenlet.wait
  File "src/gevent/_hub_primitives.py", line 46, in gevent.__hub_primitives.WaitOperationsGreenlet.wait
  File "src/gevent/_hub_primitives.py", line 55, in gevent.__hub_primitives.WaitOperationsGreenlet.wait
  File "src/gevent/_waiter.py", line 151, in gevent.__waiter.Waiter.get
  File "src/gevent/_greenlet_primitives.py", line 59, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 59, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 63, in gevent.__greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/__greenlet_primitives.pxd", line 35, in gevent.__greenlet_primitives._greenlet_switch
error: cannot switch to a different thread

黄祥

unread,
Jul 22, 2018, 6:56:30 PM7/22/18
to web2py-users
seems it's related with gevent
ref:

did you use apache as a reverse proxy and gevent as a web server?

best regards,
stifan

Alvin Ang

unread,
Jul 22, 2018, 8:47:32 PM7/22/18
to web...@googlegroups.com
Not really, I'm using Apache as web server.

Best Regards,
Alvin

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/0lJVuhiMouY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alvin Ang

unread,
Jul 24, 2018, 4:31:00 AM7/24/18
to web2py-users
seems like it's due to my Scheduler implementation within the App, I remove scheduler.py from models and App starts to work fine.

best regards,
Alvin
Reply all
Reply to author
Forward
0 new messages