我正在尝试使用Python库来使用Objective-C中的Ubutu One API.这是我的源代码:https: //github.com/JoseExposito/U1-Finder-Plugin/blob/master/U1FinderLib/U1FinderLib.py
我需要对API进行多次调用,因此我需要让我的reactor运行一次而不是运行它并停止它,就像在Ubuntu One文档的示例中一样:https: //one.ubuntu.com/developer /文件/ store_files/syncdaemontool
因为不可能运行两次反应器...而且我需要在一个线程中执行reactor.run(),因为我无法阻止使用该库的应用程序!
有可能这样做吗?我无法在一个线程中运行反应器并调用Ubuntu One API同步.
编辑:
我正在使用这个简单的源代码来测试这个想法:
#!/usr/bin/env python
import objc
import thread
import os
import time
from twisted.internet import reactor, defer
from ubuntuone.platform.tools import (SyncDaemonTool, is_already_running)
from threading import Thread
NSObject = objc.lookUpClass('NSObject')
##
# Variable to get the result of the calls to the Sync Daemon.
# The result is a JSON string stored in returned_value[0].
returned_value = ['']
##
# Objective-C facade to the methods …Run Code Online (Sandbox Code Playgroud)