[issue2475] Popen.poll always returns None
New submission from Josh Cogliati <[EMAIL PROTECTED]>: I was trying to use subprocess to run multiple processes, and then wait until one was finished. I was using poll() to do this and created the following test case: #BEGIN import subprocess,os procs = [subprocess.Popen(["sleep",str(x)]) for x in range(1,11)] while len(procs) > 0: os.wait() print [(p.pid,p.poll()) for p in procs] procs = [p for p in procs if p.poll() == None] #END I would have expected that as this program was run, it would remove the processes that finished from the procs list, but instead, they stay in it and I got the following output: #Output [(7426, None), (7427, None), (7428, None), (7429, None), (7430, None), (7431, None), (7432, None), (7433, None), (7434, None), (7435, None)] #above line repeats 8 more times [(7426, None), (7427, None), (7428, None), (7429, None), (7430, None), (7431, None), (7432, None), (7433, None), (7434, None), (7435, None)] Traceback (most recent call last): File "./test_poll.py", line 9, in os.wait() OSError: [Errno 10] No child processes #End output Basically, even for finished processes, poll returns None. Version of python used: Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26) [GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2 Relevant documentation in Library reference manual 17.1.2 poll( ) ... Returns returncode attribute. ... A None value indicates that the process hasn't terminated yet. -- messages: 64439 nosy: jjcogliati severity: normal status: open title: Popen.poll always returns None type: behavior versions: Python 2.5 __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2475> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2475] Popen.poll always returns None
Josh Cogliati <[EMAIL PROTECTED]> added the comment: Hm. Well, after filing the bug, I created a thread for each subprocess, and had that thread do an wait on the process, and that worked fine. So, I guess at minimum it sounds like the documentation for poll could be improved to mention that it will not catch the state if something else does. I think a better fix would be for poll to return some kind of UnknownError instead of None if the process was finished, but python did not catch it for some reason (like using os.wait() :) __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2475> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21401] python2 -3 does not warn about str/unicode to bytes conversions and comparisons
Josh Cogliati added the comment: Other than in the source code in Modules/main.c, is -b documented anywhere? (For 2.7.6, The html docs, man page, and --help all failed to mention it) -- nosy: +jrincayc ___ Python tracker <http://bugs.python.org/issue21401> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7028] hex function should work with floats
New submission from Josh Cogliati : The hex() builtin function only takes integers. Also there is no way to create a floating point number from a hexadecimal string. However it would often be useful to be able to see the hexadecimal version of an float since this is an exact representation as compared to the decimal version. I propose that the format 0xMantisaP0xBase2Exponent be used (but other possibilities would be fine. For example in this way 0.5 decimal would be 0x1p-0x1 hex. 1.1 decimal would be 0x8cccdp-0x33 and pi would be 0x3243f6a8885a3p-0x30 Attached are two functions I created to implement this. If this would be better as a PEP I will create one. This will cause a slight incompatibility, since now hex will throw an exception if it is passed a float. -- components: Library (Lib) files: fhex.py messages: 93389 nosy: jrincayc severity: normal status: open title: hex function should work with floats versions: Python 3.1 Added file: http://bugs.python.org/file15011/fhex.py ___ Python tracker <http://bugs.python.org/issue7028> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7028] hex function should work with floats
Changes by Josh Cogliati : -- type: -> feature request ___ Python tracker <http://bugs.python.org/issue7028> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7028] hex function should work with floats
Josh Cogliati added the comment: Thank you for telling me about that function. I read the documentation on hex() and never realized that there was a second instance method float.hex(). I am curious why the proper way to turn a number into hex is the following: import types def to_hex(a): if type(a) == type(0.0): return a.hex() elif type(a) == type(1): return hex(a) else: raise TypeError('Must be int or float') As in why does neither int.hex() or hex(float) work? Thank you. -- ___ Python tracker <http://bugs.python.org/issue7028> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7028] hex function should work with floats
Josh Cogliati added the comment: Okay. Thank you. I looked at the issue 3008 discussion. I see why hex() was not changed. Can int.hex() and int.fromhex() be added for symmetry? I am willing to work on the patch, it just might be a bit. As well, either way, it might be useful for the documentation for hex() to mention float.hex(). Thanks. -- ___ Python tracker <http://bugs.python.org/issue7028> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7028] Add int.hex for symmetry with float.hex
Josh Cogliati added the comment: Well, I think think I would at least like the sections in the Library reference documentation should mention the other functions. I.e. the following should have cross references: A. 2. Built-in Functions hex() should cross reference float.hex() B. 2. Built-in Functions float() should cross reference float.fromhex() C. 5.4.3. Additional Methods on Float float.hex() should cross reference hex() D. 5.4.3. Additional Methods on Float float.fromhex() should cross reference int(x,16) As well, the documentation strings for hex, float.hex and float.fromhex should mention the alternative functions. I am not sure about B, but I think in the documentation the alternative functions should be mentioned. I can prepare a documentation patch, if you think it would be useful (it may take a week or two). I would not have filed this bug if A. had existed since the hex documentation was the first place I looked. Thank you. -- ___ Python tracker <http://bugs.python.org/issue7028> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com