Skip to content
forked from BOINC/boinc

Commit

Permalink
remote job submission: add set_timeout() to Python API
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpanderson authored and AenBleidd committed Nov 19, 2019
1 parent 06ed2cf commit 97f62d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion lib/submit_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Python bindings of the remote job submission and file management APIs

import urllib
import urllib2
import copy
import xml.etree.ElementTree as ET
import requests
Expand Down Expand Up @@ -111,17 +112,26 @@ class REQUEST:
def __init__(self):
return

timeout = 0

def do_http_post(req, project_url, handler='submit_rpc_handler.php'):
#print req
url = project_url + handler
params = urllib.urlencode({'request': req})
f = urllib.urlopen(url, params)
if timeout>0:
f = urllib2.urlopen(url, params, timeout)
else:
f = urllib2.urlopen(url, params)
reply = f.read()
#print "REPLY:", reply
return ET.fromstring(reply)

########### API FUNCTIONS START HERE ###############

def set_timeout(x):
global timeout
timeout = x

def abort_batch(req):
req_xml = ('<abort_batch>\n'
'<authenticator>%s</authenticator>\n'
Expand Down
3 changes: 2 additions & 1 deletion tools/submit_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,5 @@ def test_get_job_counts():

#test_query_batch(328)
#test_submit_batch('batch_39')
#test_create_batch('batch_33')
set_timeout(10)
test_create_batch('batch_138')

0 comments on commit 97f62d2

Please sign in to comment.