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


Python Lock.unlock方法代码示例

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


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

示例1: BrainStudioBEClass

# 需要导入模块: from threading import Lock [as 别名]
# 或者: from threading.Lock import unlock [as 别名]

#.........这里部分代码省略.........
                                if c[2] == client_id:
                                    c[4] = True

                            connection.sendall("file loaded " + str(self.sim.get_size() - 1))

                            self.block_for_client.release()

                            # reply = dict()
                            # reply['where'] = errorin
                            # reply['what'] = 'Another client already has control. You can not send file as a slave'
                            # connection.sendall("error " + json.dumps(reply) )

                        elif self.paused:
                            print "Start recieving brn file.."
                            self.clear_sim(client_id, True)

                            recieving_file = True
                            self.filename = FILENAME
                            self.brn_file = open("./brn/" + self.filename, "w")
                            connection.sendall("give me")

                    elif data == "get file":
                        command = data.split()

                        # MUTEX HERE
                        self.block_for_local.acquire()

                        if len(self.filename) == 0:
                            reply = dict()
                            reply["where"] = "ThreadedController"
                            reply["what"] = "Can not get brain file. No simulation is running"
                            connection.sendall("error " + json.dumps(reply))
                            # MUTEX HERE
                            self.block_for_local.unlock()
                            break

                        brn_file = open(self.filename, "r")
                        data = brn_file.read()
                        brn_file.close()
                        connection.sendall("file " + data + " done")
                        self.pause(client_id)

                        self.block_for_client.acquire()

                        for c in self.clients:
                            if c[2] == client_id:
                                c[4] = True

                        self.block_for_client.release()

                        # MUTEX HERE
                        self.block_for_local.release()

                        reply = dict()
                        reply["where"] = "ThreadedController"
                        reply["what"] = "You are connected as a slave, a new brain file has been loaded"
                        connection.sendall("message " + json.dumps(reply))

                    # Format: step <number> spikes <indeces> speed <int_in_ms> stim <indeces> <current>
                    elif data[:4] == "step":
                        self.block_for_client.acquire()
                        play = not self.paused
                        self.block_for_client.release()
                        if play:
                            command = data.split()
                            if self.master == client_id:
开发者ID:brainstudio-team,项目名称:BrainStudio,代码行数:70,代码来源:ThreadedController.py


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