Exemple #1
0
def t0():
    c = http_client ('127.0.0.1', 80)
    h = header_set()
    l = [c.send_request ('GET', '/postgresql/html/', h, content=None, force=True) for x in range (10)]
    for req in l:
        req.wait()
        W ('%s\n' % (req.response,))
 def invoke(self, name, *args, **kwargs):
     if self.conn is None:
         self.conn = http_client(self.url_ob.hostname, self.url_ob.port)
     if kwargs:
         assert (not args)  # no way to mix positional & named args
         params = kwargs
     else:
         params = list(args)
     jreq = json.dumps({
         'method': name,
         'params': params,
         'id': self.counter
     })
     self.counter += 1
     if self.auth:
         req = self.conn.POST(self.url_ob.path,
                              jreq,
                              Authorization='Basic %s' % (self.auth, ))
     else:
         req = self.conn.POST(self.url_ob.path, jreq)
     if req.reply_code == '200':
         jrep = json.loads(req.content)
         return jrep['result']
     else:
         raise Error((req.reply_code, req.content))
Exemple #3
0
def t0():
    c = http_client('127.0.0.1', 80)
    h = header_set()
    l = [
        c.send_request('GET', '/postgresql/html/', h, content=None, force=True)
        for x in range(10)
    ]
    for req in l:
        req.wait()
        W('%s\n' % (req.response, ))
Exemple #4
0
 def invoke (self, name, *args, **kwargs):
     if self.conn is None:
         self.conn = http_client (self.url_ob.hostname, self.url_ob.port)
     if kwargs:
         assert (not args)  # no way to mix positional & named args
         params = kwargs
     else:
         params = list (args)
     jreq = json.dumps ({'method': name, 'params': params, 'id': self.counter})
     self.counter += 1
     if self.auth:
         req = self.conn.POST (self.url_ob.path, jreq, Authorization='Basic %s' % (self.auth,))
     else:
         req = self.conn.POST (self.url_ob.path, jreq)
     if req.reply_code == '200':
         jrep = json.loads (req.content)
         return jrep['result']
     else:
         raise Error ((req.reply_code, req.content))
Exemple #5
0
def t1():
    c = http_client ('127.0.0.1', 80)
    rl = coro.in_parallel ([(c.GET, ('/postgresql/html/',))] * 10)
    for x in rl:
        W ('%s\n' % (x.response,))
    return rl
Exemple #6
0
def t1():
    c = http_client('127.0.0.1', 80)
    rl = coro.in_parallel([(c.GET, ('/postgresql/html/', ))] * 10)
    for x in rl:
        W('%s\n' % (x.response, ))
    return rl