0

I am creating a WEB interface for various Python scripts through Django.

Example in calculation.py I would have :

import datetime
def add_time(a, b):
    return = a + b + int(datetime.datetime.now())

Usages :

  • A user could say "I want to run add from calculation.py with arguments [1, 3]" and that returns him the result when it's ready.
  • A user could say "I want this to run add from calculation.py with arguments [1, 3] every 10 minutes and check if result is greater than X" and that would action something if it's true.

Most of my script functions are quick but they need to import libraries that takes a lot of time to load.

I am currently doing this directly with my Django service ; it's simple and load the libraries once which allows most of the next calls to be very fast but sometimes a heavy call is made and that is slowing down all my Django application and I seem limited if I want to have CRON scheduling for some scripts. Therefore I am looking at another solution.

I started to look at :

  • Celery (but it seems not supported anymore on Windows)
  • Huey and Dramatiq
  • Django-Q2 (easy to use with Django)

From my understanding nothing will cache the already imported libraries. (I am fine having a "start up bulk import" if needed). Would anyone have a guess on where I should look or what above solution I can tweak ?

Requirement : I need this to run on Windows as some of my libraries are Windows dependant.

2
  • 1
    To improve performance and schedule tasks in your Django app on Windows, consider using task queue libraries like Huey, Dramatiq, or Django-Q2. Pre-load required libraries at startup to reduce overhead. Implement tasks asynchronously and schedule periodic tasks. This approach offloads heavy tasks, enhances performance, and ensures compatibility with Windows dependencies. Commented Mar 11, 2024 at 10:53
  • Dramatiq is good on windows. Commented Mar 11, 2024 at 12:13

1 Answer 1

0

In the end I used Django-q2 and used the app init to load libraries for qcluster calls

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.