Forums

PRAW and web workers

Hi again.

I have written an application which uses the PRAW API for Reddit.

PRAW has a built-in limitation that restricts requests to 1 every 2 seconds. This is established by their API guidelines.

I am aware the PythonAnywhere uses workers to keep things running smoothly. My concern is that this is going to get me into trouble with Reddit. Are workers going to break this limitation by creating multiple instances of my application?

This might be a better question to ask the PRAW people, but I'll start here first. :)

Yes. Each worker is an isolated process, so if you make a request from 1 and then immediately from another, Reddit will see that as outside of the restriction.

Thanks, Glenn.

I've switched over to use praw-multiprocess but now I get a 'Connection Refused' error whenever I try to do anything Reddit related. Reverting the changes resolves the issue. Do you know if there's anything in particular that I have to do to get this working? I started praw-multiprocess from a console and it's running on port 10101 by default.

EDIT: So it looks like what I'm trying to do might not be able to be done on PA. With this is mind, I need to restrict my web application to a single web worker to follow Reddit's API guidelines. How can I do this?

Hi there, if you got to your accounts page you can switch to a custom account with just 1 web worker.

Alternatively, maybe you could write some custom code of your own to queue up requests? Maybe have your web app add requests to a queue, and then use a scheduled task to process jobs on the queue?

Did you find any solutions for this?

Hi, @formatically.

The only solution I could think of is the one @harry posted. You'll have to write your own scheduling and maintain a central queue of requests for all workers.

Sorry I couldn't be more help!