Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove deprecated coros calls. Clearer download status.
  • Loading branch information
StephenGenusa committed Jul 23, 2015
1 parent 4cd8e1c commit 6e07290
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions mwlib/net/fetch.py
Expand Up @@ -4,7 +4,7 @@
# See README.rst for additional licensing information.

import os, sys, urlparse, urllib2, time, traceback
import gevent, gevent.pool, gevent.coros, gevent.event
import gevent, gevent.pool, gevent.lock, gevent.event

import sqlite3dbm
from lxml import etree
Expand Down Expand Up @@ -45,10 +45,11 @@ def report(self):
self.last_percent = percent

if isatty and isatty():
msg = "%s/%s %.2f %.2fs" % (done, total, percent, needed)
#msg = "%s/%s %.2f %.2fs" % (done, total, percent, needed)
msg = "%s of %s, %.2f%%, %.2f seconds," % (done, total, percent, needed)
if sys.platform in ("linux2", "linux3"):
from mwlib import linuxmem
msg += " %.1fMB" % linuxmem.resident()
msg += " %.1f MB mem used" % linuxmem.resident()
sys.stdout.write("\x1b[K" + msg + "\r")
sys.stdout.flush()

Expand Down Expand Up @@ -233,7 +234,7 @@ def __init__(self, api, fsout, pages, licenses,
imagesize=800, fetch_images=True):

self.dispatch_event = gevent.event.Event()
self.api_semaphore = gevent.coros.Semaphore(20)
self.api_semaphore = gevent.lock.Semaphore(20)

self.cover_image = cover_image

Expand Down
4 changes: 2 additions & 2 deletions mwlib/net/sapi.py
Expand Up @@ -70,8 +70,8 @@ def set_limit(self, limit=None):
if limit is None:
limit = self.api_request_limit

from gevent import coros
self.limit_fetch_semaphore = coros.Semaphore(limit)
from gevent import lock
self.limit_fetch_semaphore = lock.Semaphore(limit)

def __repr__(self):
return "<mwapi %s at %s>" % (self.apiurl, hex(id(self)))
Expand Down

0 comments on commit 6e07290

Please sign in to comment.