Пример #1
0
 def try_prolong(self):
     try:
         self.lock = self.ezekiel.prolong_tmp_lock(self.object_id, self.lock.token)
     except Exception as e:
         self.request.write(make_event(e, 'exception'))
         self.lock = None
         self.stop()
         self.request.finish()
     else:
         self.request.write(make_event(self.lock, 'prolonged'))
Пример #2
0
 def try_acquire(self):
     lock = self.ezekiel.acquire_lock(self.object_id, self.locker)
     if hasattr(lock, 'token'):
         self.lock = lock
         self.request.write(make_event(lock, 'acquired'))
         self.lc.stop()
         self.lc = LoopingCall(self.try_prolong)
         self.lc.start(self.ezekiel.long_timeout / 2, False)
     else:
         self.request.write(make_event(lock, 'rejected'))
Пример #3
0
 def try_acquire(self):
     lock = self.ezekiel.acquire_lock(self.object_id, self.locker)
     if hasattr(lock, 'token'):
         self.lock = lock
         self.request.write(make_event(lock, 'acquired'))
         self.lc.stop()
         self.lc = LoopingCall(self.try_prolong)
         self.lc.start(self.ezekiel.long_timeout / 2, False)
     else:
         self.request.write(make_event(lock, 'rejected'))
Пример #4
0
 def try_prolong(self):
     try:
         self.lock = self.ezekiel.prolong_tmp_lock(self.object_id,
                                                   self.lock.token)
     except Exception as e:
         self.request.write(make_event(e, 'exception'))
         self.lock = None
         self.stop()
         self.request.finish()
     else:
         self.request.write(make_event(self.lock, 'prolonged'))
Пример #5
0
 def __init__(self, object_id, locker, request, ezekiel):
     self.object_id = object_id
     self.locker = locker
     self.request = request
     self.ezekiel = ezekiel
     self.lock = None
     self.lc = None
     self.ka = LoopingCall(self.request.write, make_event(None, 'ping'))
Пример #6
0
 def __init__(self, object_id, locker, request, ezekiel):
     self.object_id = object_id
     self.locker = locker
     self.request = request
     self.ezekiel = ezekiel
     self.lock = None
     self.lc = None
     self.ka = LoopingCall(self.request.write, make_event(None, 'ping'))
Пример #7
0
 def send(self, message):
     """
     :type message: simargl.message.Message
     :param message:
     :return:
     """
     if message.control:
         return
     event = make_event(message)
     for request in self.requests:
         if not (message.recipient and request.user != message.recipient):
             request.write(event)
Пример #8
0
 def send(self, message):
     """
     :type message: simargl.message.Message
     :param message:
     :return:
     """
     if message.control:
         return
     event = make_event(message)
     for request in self.requests:
         if not (message.recipient and request.user != message.recipient):
             request.write(event)