Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 981887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:36:45+00:00 2026-05-16T04:36:45+00:00

Task is: I have task queue stored in db. It grows. I need to

  • 0

Task is:
I have task queue stored in db. It grows. I need to solve tasks by python script when I have resources for it. I see two ways:

  1. python script working all the time. But i don’t like it (reason posible memory leak).

  2. python script called by cron and do a little part of task. But i need to solve the problem of one working active script in memory (To prevent active scripts count grow). What is the best solution to implement it in python?

Any ideas to solve this problem at all?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:36:45+00:00Added an answer on May 16, 2026 at 4:36 am

    You can use a lockfile to prevent multiple scripts from running out of cron. See the answers to an earlier question, “Python: module for creating PID-based lockfile“. This is really just good practice in general for anything that you need to make sure won’t have multiple instances running, actually, so you should look into it even if you do have the script running constantly, which I do suggest.

    For most things, it shouldn’t be too hard to avoid memory leaks, but if you’re having a lot of trouble with it (I sometimes do with complex third-party web frameworks, for example), I would suggest instead writing the script with a small, carefully-designed main loop that monitors the database for new jobs, and then uses the multiprocessing module to fork off new processes to complete each task.

    When a task is complete, the child process can exit, immediately freeing any memory that isn’t properly garbage collected, and the main loop should be simple enough that you can avoid any memory leaks.

    This also offers the advantage that you can run multiple tasks in parallel if your system has more than one CPU core, or if your tasks spend a lot of time waiting for I/O.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a queue full of tasks which I need to submit to
I have queue of tasks for the ThreadPool, and each task has a tendency
I have a task to do, I need to take data that has been
Configuration of the Task Queue is done in the app.yaml file. There I have:
I have a queue of task in java. This queue is in a table
I have task queue that adds task to second queue, while second queue is
Google app engine task queues have configuration as (example) <queue> <name>mail-queue</name> <rate>5/m</rate> <bucket-size>10</bucket-size> </queue>
I'm using .Net 3.5 (C#) and I have a queue of tasks that I
I have as a task to simulate how queues evolve in a supermarket and
TASK : I have an existing xml document (UTF-8) which uses xml namespaces and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.