Open lambdamusic opened 5 years ago
This would be a real nice feature. I don't think so. With the new async functionality that might be a possibility too.
The technique I've used to leverage threading is to have GUI running in the main thread and other tasks running in threads.
Maybe not the most minimal example, but I do this in a project where I use easygui with a voice recognition application. Easygui runs in the main thread and voice recognition in separate threads.
the python3 process will be crashed on mac os,log is here Process: Python [28309] Path: /Versions/3.6/Resources/Python.app/Contents/MacOS/Python Identifier: org.python.python Version: 3.6.8 (3.6.8) Code Type: X86-64 (Native) Parent Process: bash [28018] Responsible: Python [28309] User ID: 501
Date/Time: 2019-11-24 09:32:44.947 +0800 OS Version: Mac OS X 10.14.6 (18G103) Report Version: 12 Anonymous UUID: 69419F4D-AB07-5E04-4214-BA46A8C49D21
Sleep/Wake UUID: 3D88DA82-392C-497F-A81A-AF264CC9BCA6
Time Awake Since Boot: 210000 seconds Time Since Wake: 1000 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler [28309]
VM Regions Near 0: --> __TEXT 00000001005f2000-00000001005f3000 [ 4K] r-x/rwx SM=COW /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libtk8.6.dylib 0x000000010108c270 TkMacOSXGetTkWindow + 63 1 libtk8.6.dylib 0x000000010108bbaf -[TKContentView(TKWindowEvent) generateExposeEvents:] + 39 2 com.apple.Foundation 0x00007fff4daf7302 NSThreadPerformPerform + 328 3 com.apple.CoreFoundation 0x00007fff4b81bde3 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 4 com.apple.CoreFoundation 0x00007fff4b81bd89 CFRunLoopDoSource0 + 108 5 com.apple.CoreFoundation 0x00007fff4b7ff74b CFRunLoopDoSources0 + 195 6 com.apple.CoreFoundation 0x00007fff4b7fed15 CFRunLoopRun + 1189 7 com.apple.CoreFoundation 0x00007fff4b7fe61e CFRunLoopRunSpecific + 455 8 libtcl8.6.dylib 0x0000000100f69708 Tcl_WaitForEvent + 267 9 libtcl8.6.dylib 0x0000000100f1fcdb Tcl_DoOneEvent + 273 10 _tkinter.cpython-36m-darwin.so 0x0000000100e524ad EventHook + 189 11 readline.cpython-36m-darwin.so 0x0000000100c7e348 call_readline + 344 12 org.python.python 0x00000001005f9ccd PyOS_Readline + 189 13 org.python.python 0x00000001005fce08 tok_nextc + 104 14 org.python.python 0x00000001005fbf47 tok_get + 2775 15 org.python.python 0x00000001005fb44e PyTokenizer_Get + 14 16 org.python.python 0x00000001005fa0a0 parsetok + 112 17 org.python.python 0x00000001006fb436 PyParser_ASTFromFileObject + 118 18 org.python.python 0x00000001006f9ed3 PyRun_InteractiveOneObjectEx + 435 19 org.python.python 0x00000001006f97e2 PyRun_InteractiveLoopFlags + 226 20 org.python.python 0x00000001006f96cc PyRun_AnyFileExFlags + 60 21 org.python.python 0x0000000100713be5 Py_Main + 3765 22 org.python.python 0x00000001005f2df8 0x1005f2000 + 3576 23 libdyld.dylib 0x00007fff777543d5 start + 1
Thread 1: 0 libsystem_pthread.dylib 0x00007fff779473f0 start_wqthread + 0
Thread 2: 0 libsystem_kernel.dylib 0x00007fff7788922a mach_msg_trap + 10 1 libsystem_kernel.dylib 0x00007fff7788976c mach_msg + 60 2 com.apple.CoreFoundation 0x00007fff4b7ff94e CFRunLoopServiceMachPort + 328 3 com.apple.CoreFoundation 0x00007fff4b7feebc CFRunLoopRun + 1612 4 com.apple.CoreFoundation 0x00007fff4b7fe61e CFRunLoopRunSpecific + 455 5 libtcl8.6.dylib 0x0000000100f69708 Tcl_WaitForEvent + 267 6 libtcl8.6.dylib 0x0000000100f1fcdb Tcl_DoOneEvent + 273 7 _tkinter.cpython-36m-darwin.so 0x0000000100e5001d _tkinter_tkapp_mainloop + 269 8 org.python.python 0x000000010064c7cb _PyCFunction_FastCallDict + 491 9 org.python.python 0x00000001006ce747 call_function + 439 10 org.python.python 0x00000001006caeb7 _PyEval_EvalFrameDefault + 27559 11 org.python.python 0x00000001006cf1af _PyEval_EvalCodeWithName + 2447 12 org.python.python 0x00000001006cfae1 fast_function + 545 13 org.python.python 0x00000001006ce721 call_function + 401 14 org.python.python 0x00000001006caeb7 _PyEval_EvalFrameDefault + 27559 15 org.python.python 0x00000001006cfa3d fast_function + 381 16 org.python.python 0x00000001006ce721 call_function + 401 17 org.python.python 0x00000001006caeb7 _PyEval_EvalFrameDefault + 27559 18 org.python.python 0x00000001006cfa3d fast_function + 381 19 org.python.python 0x00000001006ce721 call_function + 401 20 org.python.python 0x00000001006caeb7 _PyEval_EvalFrameDefault + 27559 21 org.python.python 0x00000001006cf1af _PyEval_EvalCodeWithName + 2447 22 org.python.python 0x00000001006cfae1 fast_function + 545 23 org.python.python 0x00000001006ce721 call_function + 401 24 org.python.python 0x00000001006caf56 _PyEval_EvalFrameDefault + 27718 25 org.python.python 0x00000001006cf1af _PyEval_EvalCodeWithName + 2447 26 org.python.python 0x00000001006cfae1 fast_function + 545 27 org.python.python 0x00000001006ce721 call_function + 401 28 org.python.python 0x00000001006caeb7 _PyEval_EvalFrameDefault + 27559 29 org.python.python 0x00000001006cf1af _PyEval_EvalCodeWithName + 2447 30 org.python.python 0x00000001006c42bb PyEval_EvalCodeEx + 107 31 org.python.python 0x000000010062d0cd function_call + 381 32 org.python.python 0x00000001006034f0 PyObject_Call + 96 33 org.python.python 0x00000001006cb19a _PyEval_EvalFrameDefault + 28298 34 org.python.python 0x00000001006cfa3d fast_function + 381 35 org.python.python 0x00000001006ce721 call_function + 401 36 org.python.python 0x00000001006caeb7 _PyEval_EvalFrameDefault + 27559 37 org.python.python 0x00000001006cfa3d fast_function + 381 38 org.python.python 0x00000001006ce721 call_function + 401 39 org.python.python 0x00000001006caeb7 _PyEval_EvalFrameDefault + 27559 40 org.python.python 0x00000001006cfc5c _PyFunction_FastCallDict + 348 41 org.python.python 0x00000001006036b7 _PyObject_FastCallDict + 247 42 org.python.python 0x00000001006037d5 _PyObject_Call_Prepend + 149 43 org.python.python 0x00000001006034f0 PyObject_Call + 96 44 org.python.python 0x0000000100716396 t_bootstrap + 70 45 org.python.python 0x000000010070fbe9 pythread_wrapper + 25 46 libsystem_pthread.dylib 0x00007fff779482eb _pthread_body + 126 47 libsystem_pthread.dylib 0x00007fff7794b249 _pthread_start + 66 48 libsystem_pthread.dylib 0x00007fff7794740d thread_start + 13
Thread 3: 0 libsystem_pthread.dylib 0x00007fff779473f0 start_wqthread + 0
Thread 4: 0 libsystem_pthread.dylib 0x00007fff779473f0 start_wqthread + 0
Thread 5: 0 libsystem_kernel.dylib 0x00007fff7789061a __select + 10 1 libtcl8.6.dylib 0x0000000100f69fcd NotifierThreadProc + 506 2 libsystem_pthread.dylib 0x00007fff779482eb _pthread_body + 126 3 libsystem_pthread.dylib 0x00007fff7794b249 _pthread_start + 66 4 libsystem_pthread.dylib 0x00007fff7794740d thread_start + 13
Thread 6: 0 libsystem_pthread.dylib 0x00007fff779473f0 start_wqthread + 0
Thread 0 crashed with X86 Thread State (64-bit): rax: 0x0000000000000000 rbx: 0x00007fc80716b810 rcx: 0x0000000000000000 rdx: 0x0000000000000000 rdi: 0x0000000000000109 rsi: 0x00007fc806865fd0 rbp: 0x00007ffeef60bfc0 rsp: 0x00007ffeef60bfb0 r8: 0x00000000000130a8 r9: 0x00007fc8064a1e70 r10: 0x00000001010d7d50 r11: 0x00007fc8069c97f0 r12: 0x00007fc806461a90 r13: 0x00007fff49978a3e r14: 0x00007fc8064bb3e0 r15: 0x00007fc8064bc1a0 rip: 0x000000010108c270 rfl: 0x0000000000010202 cr2: 0x0000000000000000
Logical CPU: 2 Error Code: 0x00000004 Trap Number: 14
Binary Images:
0x1005f2000 - 0x1005f2ff7 +org.python.python (3.6.8 - 3.6.8)
External Modification Summary: Calls made by other processes targeting this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by all processes on this machine: task_for_pid: 126990 thread_create: 0 thread_set_state: 0
VM Region Summary: ReadOnly portion of Libraries: Total=395.9M resident=0K(0%) swapped_out_or_unallocated=395.9M(100%) Writable regions: Total=108.4M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=108.4M(100%)
VIRTUAL REGION
REGION TYPE SIZE COUNT (non-coalesced) =========== ======= ======= Activity Tracing 256K 1 CG backing stores 5820K 1 CG image 260K 1 CoreAnimation 40K 2 CoreGraphics 8K 1 CoreUI image data 600K 4 CoreUI image file 436K 4 Dispatch continuations 8192K 1 Foundation 4K 1 Image IO 64K 1 Kernel Alloc Once 8K 1 MALLOC 69.4M 35 MALLOC guard page 32K 8 MALLOC_LARGE (reserved) 512K 2 reserved VM address space (unallocated) STACK GUARD 28K 7 Stack 23.1M 7 VM_ALLOCATE 80K 8 DATA 26.0M 267 FONT_DATA 4K 1 LINKEDIT 223.9M 21 TEXT 172.1M 267 __UNICODE 564K 1 mapped file 55.1M 16 shared memory 632K 8 =========== ======= ======= TOTAL 586.6M 666 TOTAL, minus reserved VM space 586.1M 666
Hi - I'd like to open up a text box and leave it in the background while the main python app continues running. The user will kill the text box using the OS controls at a later point.
I've tried to do that using a thread but that seems to fail. Any tips?