Python Forum

Full Version: Can I open\use threading in Python?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello
want to know if I can do this \ how

I have a code that open FTP and send files to my devices from DB list.

my problem is that it take to much time (he is wating to see if the device is online with timeout of 3500ms then open and send the files)
I have around 500 devices
so can I open ~ 10 FTP connection at the same time and them run the sending ?
that way it will take me 10 min and not 100 ~

Thanks ,
for threading see: https://docs.python.org/3/library/threading.html

you may want multiprocessing instead, if so see: https://docs.python.org/3/library/multip...processing
If I understand it correct:

pool(number) - mean how much processing to run at the same time ?

is this assumption correct:
the time that take to 1 device to update is ~ 2 sec
the time that take to say there is a problem is ~ 4 sec

so if I use pool of 5 , and 1 of them is offline
then I will get a replay after 4 sec that said:
4 units are Ok , 1 is offline ?

also the same will be for all 5 are offline ?



and another question
I have a list of IPs that I'm getting from my DB and them run it into the map function using Pool
   if __name__ == '__main__':
    print(str(datetime.now()) + '   Start Time of the program')
    run_time = 0
    Device_List = getListFromMysql()
    with Pool(5) as p:
        p.map(GetUplaudFies, Device_List)
        print(str(run_time) + ' / ' + len(Device_List))
        run_time += 1
    print(str(datetime.now()) + '   End Time of the program')
so if I have 200 IPs in the list
I want to know the pool is now on numbers 20-25 /200
when I did the above , it didn't print me the line
I want to know where am I in the count

Thanks ,