~ubuntu-branches/ubuntu/saucy/glusterfs/saucy

« back to all changes in this revision

Viewing changes to xlators/features/marker/utils/syncdaemon/syncdutils.py

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi, Louis Zuckerman, Patrick Matthäi
  • Date: 2012-01-07 14:19:57 UTC
  • mfrom: (1.3.14)
  • Revision ID: package-import@ubuntu.com-20120107141957-532c9ubquvlmzls5
Tags: 3.2.5-1
[ Louis Zuckerman ]
* Add patch (03) to fix build errors

[ Patrick Matthäi ]
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import shutil
6
6
import logging
7
7
from threading import Lock, Thread as baseThread
8
 
from errno import EACCES, EAGAIN
 
8
from errno import EACCES, EAGAIN, EINTR
9
9
from signal import SIGTERM, SIGKILL
10
10
from time import sleep
 
11
import select as oselect
 
12
from os import waitpid as owaitpid
11
13
 
12
14
from gconf import gconf
13
15
 
158
160
            kw['target'] = twrap
159
161
        baseThread.__init__(self, *a, **kw)
160
162
        self.setDaemon(True)
 
163
 
 
164
class GsyncdError(Exception):
 
165
    pass
 
166
 
 
167
def eintr_wrap(func, exc, *a):
 
168
    """
 
169
    wrapper around syscalls resilient to interrupt caused
 
170
    by signals
 
171
    """
 
172
    while True:
 
173
        try:
 
174
            return func(*a)
 
175
        except exc, ex:
 
176
            if not ex[0] == EINTR:
 
177
                raise GsyncdError(ex[1])
 
178
 
 
179
def select(*a):
 
180
    return eintr_wrap(oselect.select, oselect.error, *a)
 
181
 
 
182
def waitpid(*a):
 
183
    return eintr_wrap(owaitpid, OSError, *a)