LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-31-2018, 04:03 AM   #1
aihaike
Member
 
Registered: Feb 2006
Location: Paris, France
Distribution: Slackware, CentOS
Posts: 270

Rep: Reputation: 20
Question PyGTK3 progress bar and multiprocessing


Dear all,

I'm developing a PyGTK3 application (Linux) that copy several files to a server at the same time.
Basically, I have a batch of progress bar for each copy.
I run each copy in a process using the multiprocessing module.
In order to update the progress bar, I passed the object to the function that copy and do a set_fractional but that didn't work. I also tried to pass the value in a list as since it's mutable but still can't get the new value.

All multiprocessing examples I find talk about getting results but not about getting individual data during the process run.
That's be great if someone could shed some light on this matter to me.

Thanks.
 
Old 07-31-2018, 06:00 AM   #2
aihaike
Member
 
Registered: Feb 2006
Location: Paris, France
Distribution: Slackware, CentOS
Posts: 270

Original Poster
Rep: Reputation: 20
Question

In fact it seems the issue is summarized by the following.

In a python shell I define a function:

Code:
>>> def myfct2(n):
...   for i in range(len(n)):
...    n[i] = i
...    time.sleep(3)
Then execute it with a 'None' list:

Code:
N=[None]*4
>>> N
[None, None, None, None]
>>> myfct(N)
>>> N
[0, 1, 2, 3]
The list gets change because it's mutable.

Now, if I do the same thing in a process it behaves differently:

Code:
proc=multiprocessing.Process( target=myfct,args=(N,),daemon=True)

N=[None]*4

>>> proc.start()
>>> proc.is_alive()
True
>>> proc.is_alive()
True
>>> proc.is_alive()
True
>>> proc.is_alive()
True
>>> proc.is_alive()
True
>>> proc.is_alive()
False
>>> N
[None, None, None, None]
Can someone tell me how can I modify a mutable object passed to a function argument through a process ?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Progress bar trickydba Linux - Newbie 17 01-25-2017 12:47 PM
FIVE (5) differences between Asymmetric Multiprocessing and Symmetric Multiprocessing lightlez Linux - Newbie 1 03-05-2015 12:57 AM
mv with progress bar gbowden Linux - General 28 08-14-2013 04:42 AM
cp progress bar edwardsiow Linux - General 26 09-04-2011 08:53 AM
cp with progress bar? Rotwang Linux - General 5 04-27-2005 07:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration