Page MenuHomePhabricator

bug70177.py

Authored By
bzimport
Nov 22 2014, 3:36 AM
Size
1 KB
Referenced Files
None
Subscribers
None

bug70177.py

# -*- coding: utf-8 -*-
# Test helper for https://bugs.wikimedia.org/70177
# Fires off multiple requests to the enwiki API to parse [[en:Barack Obama]]
import json
import threading
import urllib
import urllib2
## OPTIONS ##
REQS = 3 # Number of requests to make. Requests will be made all at once.
HOST = 'mw1019' # Host to target. Should be serving en.wikipedia.org vhost.
url = 'http://%s/w/api.php' % HOST
data = urllib.urlencode({
'action': 'parse',
'format': 'json',
'prop': 'limitreportdata',
'text': urllib2.urlopen(
'https://en.wikipedia.org/wiki/Barack_Obama?action=raw'
).read(),
})
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Host': 'en.wikipedia.org',
}
def do_report():
req = urllib2.Request(url, data, headers)
resp = json.load(urllib2.urlopen(req))
print '\n'.join(
'%(name)s: %(0)s' % datum
for datum in resp['parse']['limitreportdata']
if 'time' in datum['name']
)
for i in range(REQS):
threading.Thread(target=do_report).start()

File Metadata

Mime Type
text/x-python
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
13864
Default Alt Text
bug70177.py (1 KB)

Event Timeline