# Terminating prodigy processes one by one

**URL:** <https://support.prodi.gy/t/terminating-prodigy-processes-one-by-one/5016>\
**Category:** Uncategorized\
**Tags:** usage, server\
**Created:** [November 29, 2021, 12:42pm UTC](https://support.prodi.gy/t/terminating-prodigy-processes-one-by-one/5016 "2021-11-29T12:42:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![erselekmen](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/erselekmen/32/2625_2.png) [@erselekmen](https://support.prodi.gy/u/erselekmen)\
**Post date:** [November 29, 2021, 12:42pm UTC](https://support.prodi.gy/t/terminating-prodigy-processes-one-by-one/5016/1 "2021-11-29T12:42:02Z")

</div>

Hello,  
I have assigned 40 annotation tasks to 40 students as a lecture assignment. Each task includes 1500 images to be annotated in prodigy through running them in my college's server. Now I want to create a python script that terminates one of the annotation tasks for a student in server once annotating of 1500 images of this task is done by a student in order to prevent a blocking memory usage in the server. So what way should I follow to do that?  
Thank you,

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [November 30, 2021, 9:25am UTC](https://support.prodi.gy/t/terminating-prodigy-processes-one-by-one/5016/2 "2021-11-30T09:25:08Z")

</div>

Hi! How are you serving Prodigy, are you starting multiple instances on separate hosts/ports? Or is everyone connecting to the same instance?

If you have multiple instances on different ports and your students are saving their annotations to different datasets, one solution could be to have a script that periodically checks the number of annotations in the given datasets. You can use the [`db.count_dataset`](https://prodi.gy/docs/api-database#count-dataset) method, which is more efficient than actually querying the annotations in a set. If the count is `>= 1500`, you can kill the process running on the host/port assigned to this student/dataset. For example, like this:

> <https://stackoverflow.com/questions/20691258/is-it-possible-in-python-to-kill-process-that-is-listening-on-specific-port-for>

You could then run that script periodically as a cronjob, or manually whenever you want to free up unused processes.
