This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2014年01月22日 18:24 by Craig.Silverstein, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| hang.py | Craig.Silverstein, 2014年01月22日 18:24 | Small repro of the hang (OS X 10.9 only) | ||
| Messages (8) | |||
|---|---|---|---|
| msg208838 - (view) | Author: Craig Silverstein (Craig.Silverstein) | Date: 2014年01月22日 18:24 | |
Don't ask me how, but our code managed to combine multiprocessing, sqlite, and tkinter all in one app, and got a hanging behavior, though only on a particular OS. Removing any of these removes the hang. I filed this under tkinter, but the fault could well be elsewhere. This happens for us only when run under OS X 10.9 (Mavericks). We are using python 2.7.5; I don't know if other versions are affected. |
|||
| msg208872 - (view) | Author: Ned Deily (ned.deily) * (Python committer) | Date: 2014年01月23日 01:19 | |
I can reproduce a hang (but not a crash) when using a Python 2.7.x or 3.4.x built from source and linking with the OS X 10.9 system libsqlite3. Using the Apple-supplied Python 2.7 on 10.9 causes a crash in libdispatch. Using Python 2.7.6 or 3.4.0 from the current python.org 64-bit installers, the test does not hang; these Pythons are linked with a static local version of libsqlite3, not the system-supplied one. If I modify the test to include a call to sqlite3.connect() in the top-level code before calling multiprocessing apply_async, the test also does not hang anymore. Perhaps you can use that as a workaround. I'm not sure why the combination of sqlite and _tkinter are necessary to hang. I'm not going to have time to look further into this right away. |
|||
| msg208874 - (view) | Author: Craig Silverstein (Craig.Silverstein) | Date: 2014年01月23日 01:37 | |
Thanks -- we managed to work around it by removing the tkinter dependency, so this isn't time-critical for us. It is curious, though. One thing I forgot to mention before is that playing around with the hung process in gdb, it seems like sqlite was waiting on a lock. I don't know what lock it might be though. |
|||
| msg240102 - (view) | Author: Arnon Sela (PyAcrisel) | Date: 2015年04月05日 03:56 | |
I ran into similar issue on OSX. Multiprocessing system where processes issue sqlite3.connect(). Periodically it hangs. System is using Python 3.4.3 and sqlite3; it doesn't use tkinter Noticed the following: 1. This doesn't happen on Ubuntu 2. It happens even if URL is invalid - which means that it happens before referring to URL as DB. Workaround didn't solve the problem. But it seems to reduce the frequency. And unfortunately, the system is too large and complex for it to be sent. I tried to set my environment to debug, but with no luck yet :) Thanks, |
|||
| msg240103 - (view) | Author: Ned Deily (ned.deily) * (Python committer) | Date: 2015年04月05日 04:51 | |
Arnon, what version of sqlite3 is the Python linked with? Try: python3.4 -c "import sqlite3;print(sqlite3.sqlite_version)" What kind of database access is happening in your program, i.e. strictly multi-read, one writer many reads, multiple-writers? Also, regarding the workaround, if you do call sqlite3.connect in the main process, check that you keep a reference to it (by assigning the result to a variable) so that the open connection doesn't get garbage-collected. |
|||
| msg266397 - (view) | Author: Evan Jones (evan.jones@bluecore.com) | Date: 2016年05月25日 23:07 | |
I believe the root cause of this bug is the following issue: http://bugs.python.org/issue27126 ; a workaround is to run the following code before forking any subprocesses: sqlite3.connect(':memory:').close() |
|||
| msg321658 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2018年07月14日 18:39 | |
#33111 claims that importing tkinter is enough to hang multiprocessing on MacOS up through 3.6. |
|||
| msg370342 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2020年05月29日 23:25 | |
hang.py uses the default multiprocessing start method, which was then 'fork'. It is now 'spawn' on macOS. And there have been many other changes. When I run the following from IDLE, it finishes immediately.
import multiprocessing, sqlite3
def hang():
sqlite3.connect('/tmp/foo')
if __name__ == '__main__':
multiprocessing.Pool(2).apply_async(hang, []).get(999)
print('done')
Unless I am missing something, this should be closed as 'out of date'.
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:57 | admin | set | github: 64552 |
| 2020年07月06日 08:43:04 | terry.reedy | set | status: open -> closed resolution: out of date stage: resolved |
| 2020年05月29日 23:25:34 | terry.reedy | set | messages: + msg370342 |
| 2020年05月29日 19:41:13 | erlendaasland | set | nosy:
+ erlendaasland |
| 2018年07月14日 18:39:07 | terry.reedy | set | nosy:
+ terry.reedy, ronaldoussoren messages: + msg321658 components: + macOS |
| 2017年12月12日 23:15:49 | eitan.adler | set | nosy:
+ eitan.adler |
| 2016年05月25日 23:07:09 | evan.jones@bluecore.com | set | nosy:
+ evan.jones@bluecore.com messages: + msg266397 |
| 2015年04月05日 04:51:58 | ned.deily | set | messages: + msg240103 |
| 2015年04月05日 03:56:19 | PyAcrisel | set | nosy:
+ PyAcrisel messages: + msg240102 |
| 2014年01月23日 06:41:42 | spicyj | set | nosy:
+ spicyj |
| 2014年01月23日 01:37:32 | Craig.Silverstein | set | messages: + msg208874 |
| 2014年01月23日 01:19:41 | ned.deily | set | nosy:
+ ned.deily messages: + msg208872 |
| 2014年01月22日 18:24:27 | Craig.Silverstein | create | |