python - Start a script in background when django project start -


i have script fetches data api , add data mongodb. data necessary django project. script separate project. django project single account only. number of account goes up, have setup individual project each account. (replica of each other different credentials. cannot have multiple on same project.)

i thought of cron jobs confusing seperate jobs number of accounts.

i searched subprocess.popen think serve purpose of running script in background. i.e. when project server run python script started background process.

my script like:

func1():     while true:         #         sleep(30)  func2():     while true:         #         sleep(150)  func3():     while true:         #         sleep(900)  func4():     while true:         #         sleep(7200)  if __name__ == '__main__':     p1 = process(target = func1)     p2 = process(target = func2)     p3 = process(target = func3)     p4 = process(target = func4)     p1.start()     p2.start()     p3.start()     p4.start() 

i have 2 questions:

  1. how affect system resources (memory , cpu)? okay run such kind of script in background process continuously?

  2. is there other alternative scripts starts when project run?

note: using apache mod_wsgi run project.

i try avoid never ending processes. if there memory leak in 1 of jobs?

as @user1157751 mentioned in comment, celery beat seems way go this. have documentation, celery flower provides management panel can monitor tasks.

celery website


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -