[gjc] "interrupt system call" are now handled and cause the function to be retried
This commit is contained in:
parent
42ffc5d810
commit
a8117faf2d
|
@ -104,7 +104,7 @@ def get_os_info():
|
||||||
if full_path_to_executable:
|
if full_path_to_executable:
|
||||||
command = executable + params
|
command = executable + params
|
||||||
child_stdin, child_stdout = os.popen2(command)
|
child_stdin, child_stdout = os.popen2(command)
|
||||||
output = child_stdout.readline().strip()
|
output = helpers.temp_failure_retry(child_stdout.readline).strip()
|
||||||
child_stdout.close()
|
child_stdout.close()
|
||||||
child_stdin.close()
|
child_stdin.close()
|
||||||
# some distros put n/a in places so remove them
|
# some distros put n/a in places so remove them
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
import sre
|
import sre
|
||||||
import os
|
import os
|
||||||
import urllib
|
import urllib
|
||||||
|
import errno
|
||||||
|
|
||||||
import gajim
|
import gajim
|
||||||
from common import i18n
|
from common import i18n
|
||||||
|
@ -32,6 +33,17 @@ except:
|
||||||
_ = i18n._
|
_ = i18n._
|
||||||
Q_ = i18n.Q_
|
Q_ = i18n.Q_
|
||||||
|
|
||||||
|
def temp_failure_retry(func, *args, **kwargs):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
return func(*args, **kwargs)
|
||||||
|
except (os.error, IOError), ex:
|
||||||
|
if ex.errno == errno.EINTR:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
def convert_bytes(string):
|
def convert_bytes(string):
|
||||||
suffix = ''
|
suffix = ''
|
||||||
# IEC standard says KiB = 1024 bytes KB = 1000 bytes
|
# IEC standard says KiB = 1024 bytes KB = 1000 bytes
|
||||||
|
|
|
@ -32,10 +32,22 @@ from simplexml import ustr
|
||||||
from client import PlugIn
|
from client import PlugIn
|
||||||
from protocol import *
|
from protocol import *
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
import errno
|
||||||
|
|
||||||
DATA_RECEIVED='DATA RECEIVED'
|
DATA_RECEIVED='DATA RECEIVED'
|
||||||
DATA_SENT='DATA SENT'
|
DATA_SENT='DATA SENT'
|
||||||
|
|
||||||
|
def temp_failure_retry(func, *args, **kwargs):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
return func(*args, **kwargs)
|
||||||
|
except (os.error, IOError), ex:
|
||||||
|
if ex.errno == errno.EINTR:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
class error:
|
class error:
|
||||||
"""An exception to be raised in case of low-level errors in methods of 'transports' module."""
|
"""An exception to be raised in case of low-level errors in methods of 'transports' module."""
|
||||||
def __init__(self,comment):
|
def __init__(self,comment):
|
||||||
|
@ -98,7 +110,7 @@ class TCPsocket(PlugIn):
|
||||||
try: received = self._recv(1024000)
|
try: received = self._recv(1024000)
|
||||||
except: received = ''
|
except: received = ''
|
||||||
|
|
||||||
while select.select([self._sock],[],[],0)[0]:
|
while temp_failure_retry(select.select,[self._sock],[],[],0)[0]:
|
||||||
try: add = self._recv(1024000)
|
try: add = self._recv(1024000)
|
||||||
except: add=''
|
except: add=''
|
||||||
received +=add
|
received +=add
|
||||||
|
@ -130,7 +142,7 @@ class TCPsocket(PlugIn):
|
||||||
|
|
||||||
def pending_data(self,timeout=0):
|
def pending_data(self,timeout=0):
|
||||||
""" Returns true if there is a data ready to be read. """
|
""" Returns true if there is a data ready to be read. """
|
||||||
return select.select([self._sock],[],[],timeout)[0]
|
return temp_failure_retry(select.select,[self._sock],[],[],timeout)[0]
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
""" Closes the socket. """
|
""" Closes the socket. """
|
||||||
|
|
Loading…
Reference in New Issue