The system was upgraded and everything is back online. If you experience any issues, please send an email to atlas_admin@aei.mpg.de - thanks a lot for your patience!

Unverified Commit 4458b645 authored by lfield's avatar lfield Committed by GitHub

Merge pull request #3379 from AenBleidd/dpa_rpc_timeout_for_pr

remote job submission: add an API function for setting RPC timeout
parents 06ed2cf4 4ebff8b3
......@@ -29,6 +29,8 @@
// boinc_query_job(): get details of a job
// boinc_retire_batch(): retire a batch; delete output files
// boinc_submit_batch(): submit a batch
//
// boinc_set_timeout($x): set RPC timeout to X seconds
//// Implementation stuff follows
......@@ -119,10 +121,17 @@ function validate_request($req) {
return null;
}
$rpc_timeout = 0;
function do_http_op($req, $xml, $op) {
global $rpc_timeout;
$ch = curl_init("$req->project/submit_rpc_handler.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if ($rpc_timeout) {
curl_setopt($ch, CURLOPT_TIMEOUT, $rpc_timeout);
}
// see if we need to send any files
//
......@@ -198,6 +207,12 @@ function get_error($reply, $outer_tag) {
}
//// API functions follow
function boinc_set_timeout($x) {
global $rpc_timeout;
$rpc_timeout = $x;
}
function boinc_ping($req) {
$req_xml = "<ping>
<authenticator>$req->authenticator</authenticator>
......
......@@ -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
......@@ -111,17 +112,26 @@ class REQUEST:
def __init__(self):
return
rpc_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 rpc_timeout>0:
f = urllib2.urlopen(url, params, rpc_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 rpc_timeout
rpc_timeout = x
def abort_batch(req):
req_xml = ('<abort_batch>\n'
'<authenticator>%s</authenticator>\n'
......
......@@ -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')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment