[issue27932] platform.win32_ver() leaks in 2.7.12
Okko Willeboordse added the comment: I did a gc.get_objects() before and after platform.win32_ver() and printed objects that were not present before calling platform.win32_ver(). If I run platform.win32_ver() in a loop I see the memory increasing. On 1 September 2016 at 17:35, STINNER Victor <rep...@bugs.python.org> wrote: > > STINNER Victor added the comment: > > Hum, can you please elaborate the issue? What is leaked_objects.txt? > > -- > nosy: +haypo > > ___ > Python tracker <rep...@bugs.python.org> > <http://bugs.python.org/issue27932> > ___ > -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27932> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27932] platform.win32_ver() leaks in 2.7.12
New submission from Okko Willeboordse: Running; Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32 platform.win32_ver() returns; ('10', '10.0.10586', '', u'Multiprocessor Free') -- components: Windows files: leaked_objects.txt messages: 274144 nosy: Okko.Willeboordse, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: platform.win32_ver() leaks in 2.7.12 type: resource usage versions: Python 2.7 Added file: http://bugs.python.org/file44324/leaked_objects.txt ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27932> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Event::wait with timeout gives delay
Running Python 2.6 and 2.7 on Windows 7 and Server 2012 Event::wait causes a delay when used with a timeout that is not triggered because event is set in time. I don't understand why. Can someone explain? The following program shows this; '''Shows that using a timeout in Event::wait (same for Queue::wait) causes a delay. This is perhaps caused by a polling loop inside the wait implementation. This polling loop sleeps some time depending on the timeout. Probably wait timeout 1ms = sleep = 1ms A wait with timeout can take at least this sleep time even though the event is set or queue filled much faster.''' import threading event1 = threading.Event() event2 = threading.Event() def receiver(): '''wait 4 event2, clear event2 and set event1.''' while True: event2.wait() event2.clear() event1.set() receiver_thread = threading.Thread(target = receiver) receiver_thread.start() def do_transaction(timeout): '''Performs a transaction; clear event1, set event2 and wait for thread to set event1.''' event1.clear() event2.set() event1.wait(timeout = timeout) while True: # With timeout None this runs fast and CPU bound. # With timeout set to some value this runs slow and not CPU bound. do_transaction(timeout = 10.0) -- https://mail.python.org/mailman/listinfo/python-list
[issue9090] Error code 10035 calling socket.recv() on a socket with a timeout (WSAEWOULDBLOCK - A non-blocking socket operation could not be completed immediately)
Okko Willeboordse okko.willeboor...@gmail.com added the comment: I bumped into this issue at one of my customers that use Python to control a machine through Beckhoff EtherCAT. The Python code communicates with the Beckhoff EtherCAT program using TCP/IP. They use non blocking sockets like so; s = select.select([self._socket], [], [], timeout)[0] if not s: raise NoData self._socket.recv(length) They also found that the recv occasionally raises a 10035. I changed the code in to; s = select.select([self._socket], [], [], timeout)[0] if not s: raise NoData try: buffer_ = self._socket.recv(length) except socket.error as inst: if (gaius.utils.Platform.WINDOWS and 10035 == inst.args[0]) or \ (gaius.utils.Platform.LINUX and 11 == inst.args[0]): raise NoData So this issue applies also to sockets without timeout, albeit it can be worked around easily. Also note that this also applies to Linux as the man page of select states in the BUG section; Under Linux, select() may report a socket file descriptor as ready for reading, while nevertheless a subsequent read blocks. This could for example happen when data has arrived but upon examination has wrong checksum and is discarded. There may be other circumstances in which a file descriptor is spuriously reported as ready. Thus it may be safer to use O_NONBLOCK on sockets that should not block. Note that Linux select is not Posix compliant as Posix states; A descriptor shall be considered ready for reading when a call to an input function with O_NONBLOCK clear would not block, whether or not the function would transfer data successfully. See https://lkml.org/lkml/2011/6/18/76 MSDN select says; For other sockets, readability means that queued data is available for reading such that a call to recv, WSARecv, WSARecvFrom, or recvfrom is guaranteed not to block. http://support.microsoft.com/kb/177346 says (for Windows 95); The Winsock select() API might fail to block on a nonblocking socket and return WSAEWOULDBLOCK as an error code when either send() or recv() is subsequently called. For example, select() may return indicating there is data to read, yet a call to recv() returns with the error code WSAEWOULDBLOCK, indicating there is no data immediately available. Windows NT 4.0 does not exhibit this behavior. Finally I have 2 questions; Is this select behavior on Windows 'normal'? Noting that it is not documented. or does it behaves this way due to crippled NIC's or drivers (VMWare)? Can this behavior be reproduced? I need this for automatic testing. Now these exceptional paths cannot be tested. -- nosy: +Okko.Willeboordse ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9090 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
SocketServer.ThreadingTCPServer accepts clients outside server_forever
Hello, SocketServer.ThreadingTCPServer accepts connections (clients can connect) before and after it's server_forever method is called, see below for an example. IMHO it should only accept connections while server_forever is running. Kind regards, Okko Example, both _socket.connect calls should throw; import SocketServer import threading import time import socket server = SocketServer.ThreadingTCPServer((127.0.0.1, 12345), SocketServer.BaseRequestHandler) _socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) _socket.connect((127.0.0.1, 12345)) def shutdown_server(): while not server._BaseServer__serving: time.sleep(0.1) server.shutdown() thread = threading.Thread(target = shutdown_server) thread.start() server.serve_forever() thread.join() _socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) _socket.connect((127.0.0.1, 12345)) -- http://mail.python.org/mailman/listinfo/python-list
SocketServer shutdown deadlock
All, With Python 2.5 SocketServer features the shutdown method that can be called from another thread to stop the serve_forever loop. However; When the shutdown method is called before serve_forever, shutdown will never return. This can happen when a server is stopped during startup. In other words, the following program shouldn't hang but it does; import SocketServer server = SocketServer.ThreadingTCPServer((127.0.0.1, 12345), SocketServer.BaseRequestHandler) server.shutdown() What to do? -- http://mail.python.org/mailman/listinfo/python-list
Re: SocketServer shutdown deadlock
If I wait until _BaseServer__serving is True before calling shutdown things go better. Okko Willeboordse wrote: All, With Python 2.5 SocketServer features the shutdown method that can be called from another thread to stop the serve_forever loop. However; When the shutdown method is called before serve_forever, shutdown will never return. This can happen when a server is stopped during startup. In other words, the following program shouldn't hang but it does; import SocketServer server = SocketServer.ThreadingTCPServer((127.0.0.1, 12345), SocketServer.BaseRequestHandler) server.shutdown() What to do? -- http://mail.python.org/mailman/listinfo/python-list
Re: Get code object of class
Thanks, Why do you even need the classes code object anyway? I need to instantiate and use the class in another process. This other process doesn't has access to the py or pyc file holding the m_class (source) code so I can't use pickle. Something like; In the first process (that has access to my_class (source) code) I do; c = compile(inspect.getsource(my_class), script, exec) s = marshal.dumps(c) # Send s to other process In the other process, lacking access, I do; c = marshal.loads(s) exec c in my_dict o = my_dict[my_class]() # Use o -- http://mail.python.org/mailman/listinfo/python-list
Get code object of class
To get the code object c of my_class I can do; c = compile(inspect.getsource(my_class), script, exec) This fails when inspect can't get hold of the source of my_class, for instance when my_class is in a pyc file. Is there another way of getting c? -- http://mail.python.org/mailman/listinfo/python-list
Pychecker
I execfile some script from another script like below i = 5 execfile(script) script uses i Running script standalone as well as running script through pychecker is not possible because script expects i I still need to run script through pychecker. I must do that from the calling script since it provides i (and lots more actually) Any ideas? Thanks, -- http://mail.python.org/mailman/listinfo/python-list