Skip to content

Commit 252083e

Browse files
committed
Removed praw-multiprocess and MultiProcessHandler.
1 parent ac6fcdd commit 252083e

File tree

7 files changed

+9
-254
lines changed

7 files changed

+9
-254
lines changed

CHANGES.rst

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ upstream changes.
1010
1111
.. begin_changelog_body
1212
13+
4.0.0a1
14+
-------
15+
16+
**Removed**
17+
18+
* Removed `praw-multiprocess` and its associated ``MultiprocessHandler``. This
19+
functionality is no longer needed with PRAW4.
20+
1321
3.4.0 (2016-02-21)
1422
------------------
1523

docs/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Content Pages
1919
pages/comment_parsing
2020
pages/oauth
2121
pages/lazy-loading
22-
pages/multiprocess
2322
pages/contributor_guidelines
2423
pages/configuration_files
2524
pages/faq

docs/pages/multiprocess.rst

-85
This file was deleted.

docs/pages/oauth.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ Step 2: Setting up PRAW.
5050

5151
If you want to persist instances of PRAW across multiple requests in a web
5252
application, we recommend that you create an new instance per distinct
53-
authentication. Furthermore, if your web application spawns multiple
54-
processes, it is highly recommended that you utilize PRAW's
55-
:ref:`multiprocess <multiprocess>` functionality.
53+
authentication.
5654

5755
We start as usual by importing the PRAW package and creating a :class:`.Reddit`
5856
object with a clear and descriptive useragent that follows the `api rules

praw/handlers.py

-61
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
"""Provides classes that handle request dispatching."""
22

33
from __future__ import print_function, unicode_literals
4-
5-
import socket
6-
import sys
74
import time
85
from functools import wraps
9-
from praw.errors import ClientException
106
from praw.helpers import normalize_url
117
from requests import Session
128
from six import text_type
13-
from six.moves import cPickle # pylint: disable=F0401
149
from threading import Lock
1510
from timeit import default_timer as timer
1611

@@ -181,59 +176,3 @@ def evict(cls, urls):
181176
del cls.timeouts[key]
182177
return retval
183178
DefaultHandler.request = DefaultHandler.with_cache(RateLimitHandler.request)
184-
185-
186-
class MultiprocessHandler(object):
187-
"""A PRAW handler to interact with the PRAW multi-process server."""
188-
189-
def __init__(self, host='localhost', port=10101):
190-
"""Construct an instance of the MultiprocessHandler."""
191-
self.host = host
192-
self.port = port
193-
194-
def _relay(self, **kwargs):
195-
"""Send the request through the server and return the HTTP response."""
196-
retval = None
197-
delay_time = 2 # For connection retries
198-
read_attempts = 0 # For reading from socket
199-
while retval is None: # Evict can return False
200-
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
201-
sock_fp = sock.makefile('rwb') # Used for pickle
202-
try:
203-
sock.connect((self.host, self.port))
204-
cPickle.dump(kwargs, sock_fp, cPickle.HIGHEST_PROTOCOL)
205-
sock_fp.flush()
206-
retval = cPickle.load(sock_fp)
207-
except: # pylint: disable=W0702
208-
exc_type, exc, _ = sys.exc_info()
209-
socket_error = exc_type is socket.error
210-
if socket_error and exc.errno == 111: # Connection refused
211-
sys.stderr.write('Cannot connect to multiprocess server. I'
212-
's it running? Retrying in {0} seconds.\n'
213-
.format(delay_time))
214-
time.sleep(delay_time)
215-
delay_time = min(64, delay_time * 2)
216-
elif exc_type is EOFError or socket_error and exc.errno == 104:
217-
# Failure during socket READ
218-
if read_attempts >= 3:
219-
raise ClientException('Successive failures reading '
220-
'from the multiprocess server.')
221-
sys.stderr.write('Lost connection with multiprocess server'
222-
' during read. Trying again.\n')
223-
read_attempts += 1
224-
else:
225-
raise
226-
finally:
227-
sock_fp.close()
228-
sock.close()
229-
if isinstance(retval, Exception):
230-
raise retval # pylint: disable=E0702
231-
return retval
232-
233-
def evict(self, urls):
234-
"""Forward the eviction to the server and return its response."""
235-
return self._relay(method='evict', urls=urls)
236-
237-
def request(self, **kwargs):
238-
"""Forward the request to the server and return its HTTP response."""
239-
return self._relay(method='request', **kwargs)

praw/multiprocess.py

-102
This file was deleted.

setup.py

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
description=('PRAW, an acronym for `Python Reddit API Wrapper`, is a '
3737
'python package that allows for simple access to '
3838
'reddit\'s API.'),
39-
entry_points={'console_scripts': [
40-
'praw-multiprocess = praw.multiprocess:run']},
4139
install_requires=['decorator >=4.0.9, <4.1',
4240
'requests >=2.3.0',
4341
'six ==1.10',

0 commit comments

Comments
 (0)