Print

Print


Hi,

In #329 we handled GIL issues from mixing synchronous and asynchronous callbacks.

There is still an issue remaining with shutting down the client when asynchronous callbacks were used.  From that ticket, consider this traceback:
```
Thread 4 (Thread 0x2b0ca2fec700 (LWP 1104273)):
#0  0x00002b0c9e77b790 in sem_wait () from /lib64/libpthread.so.0
#1  0x00002b0c9e4b47b5 in PyThread_acquire_lock () from /lib64/libpython2.7.so.1.0
#2  0x00002b0c9e4838a6 in PyEval_RestoreThread () from /lib64/libpython2.7.so.1.0
#3  0x00002b0c9e4a3518 in PyGILState_Ensure () from /lib64/libpython2.7.so.1.0
#4  0x00002b0ca12dff05 in PyXRootD::AsyncResponseHandler<XrdCl::ChunkInfo>::HandleResponseWithHosts(XrdCl::XRootDStatus*, XrdCl::AnyObject*, std::vector<XrdCl::HostInfo, std::allocator<XrdCl::HostInfo> >*) () from /usr/lib64/python2.7/site-packages/pyxrootd/client.so
#5  0x00002b0ca157c0be in (anonymous namespace)::StatefulHandler::HandleResponseWithHosts(XrdCl::XRootDStatus*, XrdCl::AnyObject*, std::vector<XrdCl::HostInfo, std::allocator<XrdCl::HostInfo> >*) () from /lib64/libXrdCl.so.2
#6  0x00002b0ca155f87b in XrdCl::XRootDMsgHandler::HandleResponse() () from /lib64/libXrdCl.so.2
#7  0x00002b0ca1561a38 in XrdCl::XRootDMsgHandler::Process(XrdCl::Message*) () from /lib64/libXrdCl.so.2
#8  0x00002b0ca154597e in XrdCl::Stream::HandleIncMsgJob::Run(void*) () from /lib64/libXrdCl.so.2
#9  0x00002b0ca15a6dcf in XrdCl::JobManager::RunJobs() () from /lib64/libXrdCl.so.2
#10 0x00002b0ca15a7029 in RunRunnerThread () from /lib64/libXrdCl.so.2
#11 0x00002b0c9e775dc5 in start_thread () from /lib64/libpthread.so.0
#12 0x00002b0c9f18921d in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x2b0c9e1b3880 (LWP 1104270)):
#0  0x00002b0c9e776ef7 in pthread_join () from /lib64/libpthread.so.0
#1  0x00002b0ca15a6a53 in XrdCl::JobManager::StopWorkers(unsigned int) () from /lib64/libXrdCl.so.2
#2  0x00002b0ca15a6ce6 in XrdCl::JobManager::Stop() () from /lib64/libXrdCl.so.2
#3  0x00002b0ca153e551 in XrdCl::PostMaster::Stop() () from /lib64/libXrdCl.so.2
#4  0x00002b0ca152b95a in XrdCl::DefaultEnv::Finalize() () from /lib64/libXrdCl.so.2
#5  0x00002b0c9f0cbe69 in __run_exit_handlers () from /lib64/libc.so.6
#6  0x00002b0c9f0cbeb5 in exit () from /lib64/libc.so.6
#7  0x00002b0c9e4a4b4f in Py_Exit () from /lib64/libpython2.7.so.1.0
#8  0x00002b0c9e4a4c87 in handle_system_exit.part.2 () from /lib64/libpython2.7.so.1.0
#9  0x00002b0c9e4a4f4d in PyErr_PrintEx () from /lib64/libpython2.7.so.1.0
#10 0x00002b0c9e4a5b6e in PyRun_SimpleFileExFlags () from /lib64/libpython2.7.so.1.0
#11 0x00002b0c9e4b6b9f in Py_Main () from /lib64/libpython2.7.so.1.0
#12 0x00002b0c9f0b4b15 in __libc_start_main () from /lib64/libc.so.6
#13 0x0000000000400721 in _start ()
```
This comes from a callback occurring after the python interpreter has shut down.  I observed a similar issue when the python interpreter shuts down while a callback is running in python (GIL is released periodically for fairshare between threads).

I think we're going to need a separate object whose refcount tracks the number of outstanding queries - preventing python from destroying the GIL while any are around.

---
Reply to this email directly or view it on GitHub:
https://github.com/xrootd/xrootd/issues/330

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1