Ticket #99 (defect)
Opened 4 years ago
Last modified 3 years ago
Server shutdown code fails when trying to signal "user" threads
Status: closed (fixed)
| Reported by: | cribeiro | Assigned to: | rdelon |
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | CherryPy code | Keywords: | shutdown, threads |
| Cc: |
On shutdown, the server tries to finish all CherryPy server threads, by signaling them. However, if the application has other "user-defined" threads, the code fails.
2005/01/26 10:02:11 HTTP INFO <Ctrl-C> hit: shutting down
Unhandled exception in thread started by <bound method Thread.__bootstrap of <Thread(expireCache, stopped daemon)>>
Traceback (most recent call last):
File "/usr/lib/python2.3/threading.py", line 451, in __bootstrap
self.__stop()
File "/usr/lib/python2.3/threading.py", line 460, in __stop
self.__block.notifyAll()
File "/usr/lib/python2.3/threading.py", line 256, in notifyAll
self.notify(len(self.__waiters))
File "/usr/lib/python2.3/threading.py", line 238, in notify
currentThread() # for side-effect
TypeError: 'NoneType' object is not callable
In the example above, there is one extra thread that is started by the CacheFilter?. It's a single thread, and it's set to run as a Daemon, so the server shutdown code doesn't need to worry about it. Neverthless, it tries to signal it and fail. In this case, the user thread is a single callable, and it does not support the same signaling protocol that is used by CherryPy itself to do the shutdown.
I believe that there are a few solutions for this problem:
- Server shutdown code doesn't have to worry about any other threads that are not CP core ones, and specially, 'daemonic' ones.
- Alternatively, the server shutdown code may try to signal all threads that 'conform' to the correct protocol, or that check the correct events.
- CherryPy can require that all user threads support a standard shutdown signaling protocols. (I believe that this is impossible to enforce in practice, though).
Change History
01/26/05 09:15:13: Modified by cribeiro
- priority changed from normal to low.
- severity changed from major to minor.
02/12/05 07:09:14: Modified by rboerma
Wouldn't a try...except surrounding the thread termination block be sufficient?
04/28/05 14:03:18: Modified by anonymous
please someone knows what are the shutdown code in VB 6.0.
06/14/05 13:34:30: Modified by fumanchu
- status changed from new to closed.
- resolution set to fixed.
Marked this fixed, but it's impossible to test. Reopen if the problem reoccurs for anyone.


The error is intermitent. It happens only a few times... it may be related to a race condition.