Yongzhi Pan <[email protected]> added the comment:
On macOS with Python 3.7.2, using pitrou's code, I suspect Python does not
delete some semaphores used by Queue.
Run these:
import multiprocessing
import os
import threading
os.system('lsof -p {} | grep -v txt'.format(os.getpid()))
q = multiprocessing.Queue()
q.put(1)
q.get()
threading.enumerate()
os.system('lsof -p {} | grep -v txt'.format(os.getpid()))
q.close()
threading.enumerate()
os.system('lsof -p {} | grep -v txt'.format(os.getpid()))
I see:
>>> import multiprocessing
>>> import os
>>> import threading
>>>
>>> os.system('lsof -p {} | grep -v txt'.format(os.getpid()))
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Python 56029 tux cwd DIR 1,4 96 1927156 /Users/tux/Desktop
Python 56029 tux 0u CHR 16,2 0t2867183 2393 /dev/ttys002
Python 56029 tux 1u CHR 16,2 0t2867183 2393 /dev/ttys002
Python 56029 tux 2u CHR 16,2 0t2867183 2393 /dev/ttys002
0
>>> q = multiprocessing.Queue()
>>> q.put(1)
>>> q.get()
1
>>> threading.enumerate()
[<_MainThread(MainThread, started 4570830272)>, <Thread(QueueFeederThread,
started daemon 123145368662016)>]
>>> os.system('lsof -p {} | grep -v txt'.format(os.getpid()))
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Python 56029 tux cwd DIR 1,4 96 1927156
/Users/tux/Desktop
Python 56029 tux 0u CHR 16,2 0t2867914 2393
/dev/ttys002
Python 56029 tux 1u CHR 16,2 0t2867914 2393
/dev/ttys002
Python 56029 tux 2u CHR 16,2 0t2867914 2393
/dev/ttys002
Python 56029 tux 3 PIPE 0x5ab56e2f13ca4abb 16384
->0x5ab56e2f13ca5a7b
Python 56029 tux 4 PIPE 0x5ab56e2f13ca5a7b 16384
->0x5ab56e2f13ca4abb
Python 56029 tux 5r PSXSEM 0t0
/mp-oa1x27kb
Python 56029 tux 6r PSXSEM 0t0
/mp-khu1swie
Python 56029 tux 7r PSXSEM 0t0
/mp-pwrgzmzz
0
>>> q.close()
>>> threading.enumerate()
[<_MainThread(MainThread, started 4570830272)>]
>>> os.system('lsof -p {} | grep -v txt'.format(os.getpid()))
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Python 56029 tux cwd DIR 1,4 96 1927156 /Users/tux/Desktop
Python 56029 tux 0u CHR 16,2 0t2869010 2393 /dev/ttys002
Python 56029 tux 1u CHR 16,2 0t2869010 2393 /dev/ttys002
Python 56029 tux 2u CHR 16,2 0t2869010 2393 /dev/ttys002
Python 56029 tux 5r PSXSEM 0t0 /mp-oa1x27kb
Python 56029 tux 6r PSXSEM 0t0 /mp-khu1swie
Python 56029 tux 7r PSXSEM 0t0 /mp-pwrgzmzz
The three PSXSEM persists even after some time. Is this some type of leakage?
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33081>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com