Discuss / Python / 同一台机器上,代码可以正常运行

同一台机器上,代码可以正常运行

Topic source

中大-雪山

#1 Created at ... [Delete] [Delete and Lock User]

我用的Cygwin 的linux 模拟器,python 为3.6,这个运行task_master.py

然后用windows下的命令提示符,运行的task_worker.py,安装的也是Python 3.6.然后修改了ip地址。ip地址可以使用命令提示符,输入ipconfig 查看ip地址。

中大-雪山

#2 Created at ... [Delete] [Delete and Lock User]

但如果在命令提示符下运行task_master.py 直接就报错了~

C:\Windows\System32>python D:\cygwin64\home\yl.lee\task_master.py Traceback (most recent call last): File "D:\cygwin64\home\yl.lee\task_master.py", line 21, in <module> manager.start() File "D:\Users\yl.lee\Anaconda3\lib\multiprocessing\managers.py", line 513, in start self._process.start() File "D:\Users\yl.lee\Anaconda3\lib\multiprocessing\process.py", line 105, in start self._popen = self._Popen(self) File "D:\Users\yl.lee\Anaconda3\lib\multiprocessing\context.py", line 322, in _Popen return Popen(process_obj) File "D:\Users\yl.lee\Anaconda3\lib\multiprocessing\popen_spawn_win32.py", lin e 65, in init reduction.dump(process_obj, to_child) File "D:\Users\yl.lee\Anaconda3\lib\multiprocessing\reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) _pickle.PicklingError: Can't pickle <function <lambda> at 0x0000000001D43E18>: a ttribute lookup <lambda> on main failed C:\Windows\System32>Traceback (most recent call last): File "<string>", line 1, in <module> File "D:\Users\yl.lee\Anaconda3\lib\multiprocessing\spawn.py", line 99, in spa wn_main new_handle = reduction.steal_handle(parent_pid, pipe_handle) File "D:\Users\yl.lee\Anaconda3\lib\multiprocessing\reduction.py", line 82, in steal_handle _winapi.PROCESS_DUP_HANDLE, False, source_pid) OSError: [WinError 87] 参数错误。

文16249

#3 Created at ... [Delete] [Delete and Lock User]

好像是pickle的问题,我在Windows下运行也是报出Can't pickle <function <lambda> at 0x0000000001D43E18>: a ttribute lookup <lambda> on main failed这个错,将callable=lambda: task_queue改成 callable=task_q def task_q(): return task_queue 就ok了

Mr_Xj豪

#4 Created at ... [Delete] [Delete and Lock User]

为什么我改了 还是不对,我也是在windows下cmd运行的。 QueueManager.register('get_task_queue', callable=lambda: task_queue) QueueManager.register('get_result_queue', callable=lambda: result_queue) 请问 是这两句都要改吗??


  • 1

Reply