~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Lib/multiprocessing/connection.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#
28
28
 
29
29
BUFSIZE = 8192
 
30
# A very generous timeout when it comes to local connections...
 
31
CONNECTION_TIMEOUT = 20.
30
32
 
31
33
_mmap_counter = itertools.count()
32
34
 
41
43
    default_family = 'AF_PIPE'
42
44
    families += ['AF_PIPE']
43
45
 
 
46
 
 
47
def _init_timeout(timeout=CONNECTION_TIMEOUT):
 
48
    return time.time() + timeout
 
49
 
 
50
def _check_timeout(t):
 
51
    return time.time() > t
 
52
 
44
53
#
45
54
#
46
55
#
247
256
    '''
248
257
    family = address_type(address)
249
258
    s = socket.socket( getattr(socket, family) )
 
259
    t = _init_timeout()
250
260
 
251
261
    while 1:
252
262
        try:
253
263
            s.connect(address)
254
264
        except socket.error, e:
255
 
            if e.args[0] != errno.ECONNREFUSED: # connection refused
 
265
            if e.args[0] != errno.ECONNREFUSED or _check_timeout(t):
256
266
                debug('failed to connect to address %s', address)
257
267
                raise
258
268
            time.sleep(0.01)
322
332
        '''
323
333
        Return a connection object connected to the pipe given by `address`
324
334
        '''
 
335
        t = _init_timeout()
325
336
        while 1:
326
337
            try:
327
338
                win32.WaitNamedPipe(address, 1000)
331
342
                    )
332
343
            except WindowsError, e:
333
344
                if e.args[0] not in (win32.ERROR_SEM_TIMEOUT,
334
 
                                     win32.ERROR_PIPE_BUSY):
 
345
                                     win32.ERROR_PIPE_BUSY) or _check_timeout(t):
335
346
                    raise
336
347
            else:
337
348
                break