Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

back to the basics 8)

samus_1fa5c7bade3b
diff --git a/scrapy/trunk/scrapy/contrib/pbcluster/worker/manager.py b/scrapy/trunk/scrapy/contrib/pbcluster/worker/manager.py
index 906934ec9..c45d7b032 100644
--- a/scrapy/trunk/scrapy/contrib/pbcluster/worker/manager.py
+++ b/scrapy/trunk/scrapy/contrib/pbcluster/worker/manager.py
@@ -1,4 +1,3 @@
-from __future__ import with_statement
import sys, os, time, datetime, pickle, gzip
from twisted.internet import protocol, reactor
@@ -41,9 +40,11 @@ class ScrapyProcessProtocol(protocol.ProcessProtocol):
def processEnded(self, reason):
if settings.getbool('CLUSTER_WORKER_GZIP_LOGS'):
try:
- with open(self.logfile) as f_in:
- with gzip.open("%s.gz" % self.logfile, "wb") as f_out:
- f_out.writelines(f_in)
+ f_in = open(self.logfile)
+ f_out = gzip.open("%s.gz" % self.logfile, "wb")
+ f_out.writelines(f_in)
+ f_in.close()
+ f_out.close()
os.remove(self.logfile)
self.logfile = "%s.gz" % self.logfile
except Exception, e: