Beispiel #1
0
    def on(self, id, func):
        if id == self.bot.client.config.shard_id:
            result = gevent.event.AsyncResult()
            result.set(func(self.bot))
            return result

        return self.bot.sharder.call(('run_on', ), id, dump_function(func))
Beispiel #2
0
 def execute(self, func):
     nonce = get_random_str(32)
     raw = dump_function(func)
     self.results[nonce] = result = gevent.event.AsyncResult()
     self.pipe.put((IPCMessageType.EXECUTE.value, (nonce, raw)))
     return result