issue #406: 3.x syntax fixes.

issue260
David Wilson 6 years ago
parent 586c6aca9a
commit e01c8f2891

@ -10,7 +10,6 @@ import threading
import time import time
import traceback import traceback
import psutil
import unittest2 import unittest2
import mitogen.core import mitogen.core
@ -49,6 +48,7 @@ def get_fd_count():
""" """
Return the number of FDs open by this process. Return the number of FDs open by this process.
""" """
import psutil
return psutil.Process().num_fds() return psutil.Process().num_fds()
@ -185,10 +185,9 @@ def log_fd_calls():
with l: with l:
rv = real_pipe() rv = real_pipe()
if mypid == os.getpid(): if mypid == os.getpid():
print sys.stdout.write('\n%s\n' % (rv,))
print rv
traceback.print_stack(limit=3) traceback.print_stack(limit=3)
print sys.stdout.write('\n')
return rv return rv
os.pipe = pipe os.pipe = pipe
@ -197,10 +196,9 @@ def log_fd_calls():
with l: with l:
rv = real_socketpair(*args) rv = real_socketpair(*args)
if mypid == os.getpid(): if mypid == os.getpid():
print sys.stdout.write('\n%s -> %s\n' % (args, rv))
print '--', args, '->', rv
traceback.print_stack(limit=3) traceback.print_stack(limit=3)
print sys.stdout.write('\n')
return rv return rv
socket.socketpair = socketpair socket.socketpair = socketpair
@ -209,10 +207,9 @@ def log_fd_calls():
with l: with l:
real_dup2(*args) real_dup2(*args)
if mypid == os.getpid(): if mypid == os.getpid():
print sys.stdout.write('\n%s\n' % (args,))
print '--', args
traceback.print_stack(limit=3) traceback.print_stack(limit=3)
print sys.stdout.write('\n')
os.dup2 = dup2 os.dup2 = dup2
real_dup = os.dup real_dup = os.dup
@ -220,10 +217,9 @@ def log_fd_calls():
with l: with l:
rv = real_dup(*args) rv = real_dup(*args)
if mypid == os.getpid(): if mypid == os.getpid():
print sys.stdout.write('\n%s -> %s\n' % (args, rv))
print '--', args, '->', rv
traceback.print_stack(limit=3) traceback.print_stack(limit=3)
print sys.stdout.write('\n')
return rv return rv
os.dup = dup os.dup = dup

Loading…
Cancel
Save