Skip to content

Commit

Permalink
fix multiprocess bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ppwwyyxx committed Jan 4, 2016
1 parent 15a71ca commit 2209f31
Show file tree
Hide file tree
Showing 6 changed files with 388 additions and 5 deletions.
381 changes: 381 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup
kwargs = dict(
name = 'sopaper',
version = '0.1',
version = '0.2',
description = 'Automatically search and download paper',
author = 'Yuxin Wu',
author_email = '[email protected]',
Expand Down
4 changes: 2 additions & 2 deletions sopaper/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
# File: paper-downloader.py
# File: __main__.py
# Author: Yuxin Wu <[email protected]>

# Command line script to use paper-downloader
Expand Down Expand Up @@ -71,7 +71,7 @@ def main():
#results = [searcher_run(*arg) for arg in search_args] # for debug

for s in as_results:
s = s.get()
s = s.get(ukconfig.PYTHON_POOL_TIMEOUT)
if s is None:
continue
ctx.update_meta_dict(s['ctx_update'])
Expand Down
1 change: 0 additions & 1 deletion sopaper/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from lib.textutil import title_beautify
from lib.ukutil import ensure_unicode
from uklogger import *
from multiprocessing import Pool

class JobContext(object):
def __init__(self, query):
Expand Down
3 changes: 2 additions & 1 deletion sopaper/queryhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from pdfprocess import postprocess
from lib.downloader import ProgressPrinter
from contentsearch import SoPaperSearcher
import ukconfig

# global. save all ongoing download
progress_dict = {}
Expand Down Expand Up @@ -83,7 +84,7 @@ def handle_title_query(query):
# Search and get all the results item
all_search_results = []
for s in async_results:
s = s.get()
s = s.get(ukconfig.PYTHON_POOL_TIMEOUT)
if s is None:
continue
srs = s['results']
Expand Down
2 changes: 2 additions & 0 deletions sopaper/ukconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
FILE_SIZE_MINIMUM = 10000 # at least 10kb
FILE_SIZE_MAXIMUM = 100000000 # at most 100mb

PYTHON_POOL_TIMEOUT = 9999 # bug in python: see http://stackoverflow.com/questions/1408356/keyboard-interrupts-with-pythons-multiprocessing-pool

import os

LOG_DIR = None
Expand Down

0 comments on commit 2209f31

Please sign in to comment.