Python Forum
Can I open\use threading in Python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can I open\use threading in Python?
#1
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 ,
Reply
#2
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
Reply
#3
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 ,
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Concurrent futures threading running at same speed as non-threading billykid999 13 1,826 May-03-2023, 08:22 AM
Last Post: billykid999
  Tutorials on sockets, threading and multi-threading? muzikman 2 2,122 Oct-01-2021, 08:32 PM
Last Post: muzikman
  Embedding python cause crash when use boost::asio multi threading udvatt108 0 1,720 Oct-04-2020, 03:15 PM
Last Post: udvatt108
  Python - Keyboard module - Threading problem ppel123 1 3,073 Apr-13-2020, 04:49 PM
Last Post: deanhystad
  Help Threading python robot lucandmendes 0 9,323 May-03-2018, 02:42 PM
Last Post: lucandmendes
  Problem with Python, MySQL and Multi-threading queries zagk 1 11,893 Jul-01-2017, 12:15 AM
Last Post: zagk
  Python Threading Amro_Al 3 4,900 Oct-30-2016, 03:11 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020