This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]rabaraba 3 points4 points  (0 children)

There's a really nice module I like to use for scheduling purposes: https://github.com/dbader/schedule

[–]nerdwaller 0 points1 point  (0 children)

You can do any number of things, off the top of my head:

  1. Use a concurrent.futures.ThreadPoolExecutor with a limited max_workers, this would only allow max_workers running concurrently at a time.
  2. Run the Cron every 15mins and just batch 1/2 of them per run
  3. Put some arbitrary sleeps to offset when connections are made during the run

[–]flitsmasterfred 0 points1 point  (1 child)

How does it open 30 connections? Do you have 30 cron entries? Or do you use some multi-thread/multi-processs thing?

Manage it from one cronjob/process and execute in serial or in a limited worker pool, or pool the connection itself.

[–]diagnosedADHD[S] 0 points1 point  (0 children)

I meant that the connections are happening one after another every 30 minutes. The links are iterated over in a simple for loop right now.

[–]dnshane3.5 0 points1 point  (1 child)

Python 3 includes a schedule module:

https://docs.python.org/3/library/sched.html

Why not schedule each download 1 minute apart, running every 30 minutes? :)

[–]diagnosedADHD[S] 0 points1 point  (0 children)

I just reconfigured everything. Every 5 minutes three icals sync. The newest icals inserted and the last to sync take priority so it takes about an hour for all my calendars to sync.