我有一个非常简单的过程,看来它没有在paralell中运行。
这里有一个例子来说明这一点:
import requests
repo = 'MyOrg/my-repo'
branch = 'master'
access_token = 'YourToken'
r = requests.put(
'https://api.github.com/repos/{0}/branches/{1}/protection'.format(repo, branch),
headers = {
'Accept': 'application/vnd.github.luke-cage-preview+json',
'Authorization': 'Token {0}'.format(access_token)
},
json = {
"restrictions": {
"users": [
"bertrandmartel"
],
"teams": [
"my-team"
]
},
"required_status_checks": None,
"enforce_admins": None,
"required_pull_request_reviews": None
}
)
print(r.status_code)
print(r.json())
所以我有以下代码。
class BattleQueueProcess(Process):
def __init__(self):
self._runWorker = True
super(Process, self).__init__()
def run(self):
while self._runWorker:
print('loop')
time.sleep(1)
def stop(self):
self._runWorker = False
self.join()
self.terminate()
但是我的输出是
“开始” 环 环 环 ...等等
“开始”永远不会打印。
为什么进程不能并行运行?
答案 0 :(得分:0)
在您的BattleQueueProcess
类中,__init__()
方法中存在错误。您对super
的呼叫应该是:
super(BattleQueueProcess, self).__init__()
不是:
super(Process, self).__init__()