当前位置: 首页>>代码示例>>Python>>正文


Python ActorRegistry.get_by_urn方法代码示例

本文整理汇总了Python中pykka.ActorRegistry.get_by_urn方法的典型用法代码示例。如果您正苦于以下问题:Python ActorRegistry.get_by_urn方法的具体用法?Python ActorRegistry.get_by_urn怎么用?Python ActorRegistry.get_by_urn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pykka.ActorRegistry的用法示例。


在下文中一共展示了ActorRegistry.get_by_urn方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_pactor_ref

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
 def get_pactor_ref(self):
     """Get a reference to a pykka actor for this."""
     if not self.is_active():
         raise NotRunningError("This game is not active.")
     else:
         actor_urn = cache.get(str(self.uuid))
         actor_ref = ActorRegistry.get_by_urn(actor_urn)
     return actor_ref
开发者ID:lexpar,项目名称:CTeam,代码行数:10,代码来源:game_instance.py

示例2: on_receive

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
    def on_receive(self, msg):
        if msg['type'] == 'config':
            # Set the sixteenth note period for this Actor
            self.period = 1.0/msg['bpm']*60.0 / 4.0

            # Get NoteActor URN
            self.target = ActorRegistry.get_by_urn(msg['target'])
            self.tick(0)
        elif msg['type'] == 'play': self.playing = True; self.tick(0)
        elif msg['type'] == 'stop': self.playing = False
开发者ID:danpprince,项目名称:euclidean-seq,代码行数:12,代码来源:actors.py

示例3: is_active

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
 def is_active(self):
     actor_urn = cache.get(str(self.uuid))
     if actor_urn:
         if ActorRegistry.get_by_urn(actor_urn):
             return True
         else:
             cache.delete(str(self.uuid))
             return False
     else:
         return False
开发者ID:lexpar,项目名称:CTeam,代码行数:12,代码来源:game_instance.py

示例4: reply

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
    def reply(self, message, text, opts=None):
        """
        Reply to the sender of the provided message with a message \
        containing the provided text.

        :param message: the message to reply to
        :param text: the text to reply with
        :param opts: A dictionary of additional values to add to metadata
        :return: None
        """
        metadata = Metadata(source=self.actor_urn,
                            dest=message['metadata']['source']).__dict__
        metadata['opts'] = opts
        message = Message(text=text, metadata=metadata,
                          should_log=message['should_log']).__dict__
        dest_actor = ActorRegistry.get_by_urn(message['metadata']['dest'])
        if dest_actor is not None:
            dest_actor.tell(message)
        else:
            raise("Tried to send message to nonexistent actor")
开发者ID:bbriggs,项目名称:Legobot,代码行数:22,代码来源:Lego.py

示例5: test_get_by_urn_returns_none_if_not_found

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
 def test_get_by_urn_returns_none_if_not_found(self):
     result = ActorRegistry.get_by_urn('urn:foo:bar')
     self.assertEqual(None, result)
开发者ID:0xD3ADB33F,项目名称:pykka,代码行数:5,代码来源:registry_test.py

示例6: test_actors_may_be_looked_up_by_urn

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
 def test_actors_may_be_looked_up_by_urn(self):
     result = ActorRegistry.get_by_urn(self.a_actor_0_urn)
     self.assertEqual(self.a_actors[0], result)
开发者ID:0xD3ADB33F,项目名称:pykka,代码行数:5,代码来源:registry_test.py

示例7: __init__

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
    def __init__(self, root, timing_act_urn, note_act_urn):
        # Make this thread a daemon so it ends when the main thread exits
        super(GuiActor, self).__init__(use_daemon_thread=True)
        self.widgets = []

        # Set up transport controls
        timing_actor = ActorRegistry.get_by_urn(timing_act_urn)
        def make_transport_cb(msg):
            return lambda: timing_actor.tell({'type': msg})

        frame = tk.Frame(root, padx=5)
        play_b = tk.Button(frame, width=5, text='Play')
        stop_b = tk.Button(frame, width=5, text='Stop')
        play_b.config(command=make_transport_cb('play'))
        stop_b.config(command=make_transport_cb('stop'))

        play_b.grid(row=0, column=0, padx=10, pady=10)
        stop_b.grid(row=1, column=0, padx=10, pady=10)
        frame .grid(row=0, column=0)

        # Set up tk GUI
        # Create each sequencer frame
        note_actor = ActorRegistry.get_by_urn(note_act_urn)
        seq_names = ['Kick', 'Snare', 'Cl. HiHat', 'Op. HiHat', 'Clave', 'Cowbell']
        for idx in range(6):
            frame = tk.Frame(root, borderwidth=1, padx=5, relief=tk.RIDGE)
            seq_label = tk.Label (frame, text=seq_names[idx])
            k_label   = tk.Label (frame, text='k:')
            k_entry   = tk.Entry (frame, width=5)
            n_label   = tk.Label (frame, text='n:')
            n_entry   = tk.Entry (frame, width=5)
            start_b   = tk.Button(frame, width=7, text='Start')
            mute_b    = tk.Button(frame, width=7, text='Mute')

            # Capture the current sequence index, sequence k Entry object,
            # and sequence n Entry object with a closure in order to keep
            # references to them in the callback for this start button
            def make_start_cb(seq_idx, seq_k, seq_n):
                # Send a message to the NoteActor with the info
                # from this sequence's config frame
                return lambda: note_actor.tell({'type': 'seq-config', 
                                                'seq_num': seq_idx, 
                                                'k': int(seq_k.get()), 
                                                'n': int(seq_n.get())})
            start_b.config(command=make_start_cb(idx, k_entry, n_entry))

            # Capture the current sequence index, with a closure to use them
            # in a callback for the mute button
            def make_mute_cb(seq_idx):
                return lambda: note_actor.tell({'type': 'seq-mute', 
                                                'seq_num': seq_idx})
            mute_b.config(command=make_mute_cb(idx))

            seq_label.grid(row=0, column=0, columnspan=2)
            k_label  .grid(row=1, column=0, padx=5)
            n_label  .grid(row=2, column=0, padx=5)
            k_entry  .grid(row=1, column=1)
            n_entry  .grid(row=2, column=1)
            start_b  .grid(row=3, column=0, pady=5, columnspan=2)
            mute_b   .grid(row=4, column=0, pady=5, columnspan=2)

            frame.grid(row=0, column=idx+1)
            self.widgets.append([frame, seq_label, k_label, n_label])
开发者ID:danpprince,项目名称:euclidean-seq,代码行数:65,代码来源:actors.py

示例8: _iap

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
def _iap(pid):
    player = get_player(pid)
    print (ActorRegistry.get_by_urn(pid))
    future = player.proxy().pprint({'message':'%s' % pid})
    return future.get()
开发者ID:hugo-zheng,项目名称:inttest,代码行数:7,代码来源:listener.py

示例9: test_get_by_urn_returns_none_if_not_found

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
def test_get_by_urn_returns_none_if_not_found():
    result = ActorRegistry.get_by_urn('urn:foo:bar')

    assert result is None
开发者ID:jodal,项目名称:pykka,代码行数:6,代码来源:test_registry.py

示例10: test_actors_may_be_looked_up_by_urn

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
def test_actors_may_be_looked_up_by_urn(actor_ref):
    result = ActorRegistry.get_by_urn(actor_ref.actor_urn)

    assert result == actor_ref
开发者ID:jodal,项目名称:pykka,代码行数:6,代码来源:test_registry.py

示例11: on_failure

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
 def on_failure(self, exception_type, exception_value, traceback):
     ref = ActorRegistry.get_by_urn(self.actor_urn)
     logger.exception('Lego crashed: ' + str(ref))
     logger.exception(exception_type)
     logger.exception(exception_value)
开发者ID:bbriggs,项目名称:Legobot,代码行数:7,代码来源:Lego.py

示例12: get_player

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
def get_player(pid):
    player = ActorRegistry.get_by_urn(pid)
    if player is None:
        player =  Player.start(pid)

    return player
开发者ID:hugo-zheng,项目名称:inttest,代码行数:8,代码来源:base_actor.py

示例13: on_start

# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import get_by_urn [as 别名]
 def on_start(self):
     self.on_start_was_called.set()
     if ActorRegistry.get_by_urn(self.actor_urn) is not None:
         self.actor_was_registered_before_on_start_was_called.set()
开发者ID:0xD3ADB33F,项目名称:pykka,代码行数:6,代码来源:actor_test.py


注:本文中的pykka.ActorRegistry.get_by_urn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。