Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multithreading question
#1
Hello,
I'm working on a program to interpolate video frames taking advantage of multithreading or multiprocessing to better take advantage of the idle cpu and gpu times i saw while monitoring.
The function i want to run in parallel or at least with multithreading looks like this at the moment:
def interpolate(thread_id):
	total_sections = 100
	section_index = 0
	if thread_id == 1:
		section_index += 1 
	start_frame = 1
	final_frame = 24
	while section_index < total_sections:
		while start_frame < final_frame:
			#do the interpolation here
			start_frame += 1
		section_index += 2
	
	
id = 0
interpolateT0 = multithreading.Thread(target=interpolate, args=(id,))
id = 1
interpolateT1 = multithreading.Thread(target=interpolate, args=(id,))

interpolateT0.start()
time.sleep(4)
interpolateT1.start()			
The point is that thread 1 starts with a offset of 1 for the section index, and also +2 is added instead of +1 to the section index so that essentialy thread 0 does sections with pair index number and thread 1 does those with odd numbers.

But i don't think this will work because the both threads will update the same values and everything will get out of place. That's why i thought that using multiprocessing would be better? But it seems that using the debugger for multiprocessing is not possible?
any help?
thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter Web Scraping w/Multithreading Question.... AaronCatolico1 3 1,252 Dec-16-2022, 11:34 AM
Last Post: deanhystad
  Python Tkinter Simple Multithreading Question AaronCatolico1 5 1,570 Dec-14-2022, 11:35 PM
Last Post: deanhystad
  multithreading Hanyx 4 1,325 Jul-29-2022, 07:28 AM
Last Post: Larz60+
Question Problems with variables in multithreading Wombaz 2 1,324 Mar-08-2022, 03:32 PM
Last Post: Wombaz
  How can i add multithreading in this example WoodyWoodpecker1 3 2,511 Aug-11-2020, 05:30 PM
Last Post: deanhystad
  matplotlib multithreading catosp 0 2,950 Jul-03-2020, 09:33 AM
Last Post: catosp
  Multithreading dynamically syncronism Rodrigo 0 1,534 Nov-08-2019, 02:33 AM
Last Post: Rodrigo
  Locks in Multithreading Chuonon 0 1,845 Oct-03-2019, 04:16 PM
Last Post: Chuonon
  multithreading issue with output mr_byte31 4 3,200 Sep-11-2019, 12:04 PM
Last Post: stullis
  Multithreading alternative MartinV279 1 2,789 Aug-01-2019, 11:41 PM
Last Post: scidam

Forum Jump:

User Panel Messages

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