Пример #1
0
 def _logThr(self):
     while True:
         if self._cs_state == CsState.IN:
             commutils.log('Working with resource')
         elif self._cs_state == CsState.TRYING:
             commutils.log('Trying ...')
         else:
             commutils.log('Resting...')
         sleep(1)
Пример #2
0
 def _log_daemon(self):
     while True:
         if self._cs_state == CsState.IN:
             commutils.log('Working with {0} resources'.format(
                 self._used_by[self._id]))
         elif self._cs_state == CsState.TRYING:
             commutils.log('Trying for {0} resources'.format(
                 self._used_by[self._id]))
         else:
             commutils.log('Resting...')
         sleep(1)
 def _log_daemon(self):
     while True:
         # print(self._cs_state)
         if any(map(lambda s: self._cs_state[s] == CsState.TRYING, self._cs_state)):
             commutils.log('Trying for {0} resources'.format(
                 [self._used_by[i][self._id] for i in self._cs_state]))
         elif any(map(lambda s: self._cs_state[s] == CsState.IN, self._cs_state)):
             commutils.log('Working with {0} resources'.format(
                 [self._used_by[i][self._id] for i in self._cs_state]))
         else:
             commutils.log('Resting...')
         sleep(1)
 def _log(self, msg, *args, **kwargs):
     if self.logging:
         M = '{:15}: {}'.format(type(self).__name__, msg)
         commutils.log(M, *args, **kwargs)