Re: [Matplotlib-users] matplotlib threadsafe?

2008-04-09 Thread Chris Withers
Eric Firing wrote:
 
 Out of interest, how does one tell MPL to start a new figure and 
 forget everything that's gone before?
 
 You can minimize the amount of package and module-level state 
 information by using the oo interface: see examples/agg_oo.py.

I tried this example, and it generates no output.
Is that to be expected?

cheers,

Chris

-- 
Simplistix - Content Management, Zope  Python Consulting
- http://www.simplistix.co.uk

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib threadsafe?

2008-04-09 Thread Eric Firing
Chris Withers wrote:
 Eric Firing wrote:

 Out of interest, how does one tell MPL to start a new figure and 
 forget everything that's gone before?

 You can minimize the amount of package and module-level state 
 information by using the oo interface: see examples/agg_oo.py.
 
 I tried this example, and it generates no output.
 Is that to be expected?

Chris,

It should produce a test.png; it is using a non-interactive backend. 
It works on my machine.

Eric

 
 cheers,
 
 Chris
 


-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib threadsafe?

2008-03-21 Thread Eric Firing

 Out of interest, how does one tell MPL to start a new figure and forget 
 everything that's gone before?

You can minimize the amount of package and module-level state 
information by using the oo interface: see examples/agg_oo.py.  If you 
change any rcParams dictionary entries, typically using the rc function, 
then you can restore the dictionary to its default condition with the 
rcdefaults() function.

Eric


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib threadsafe?

2008-03-21 Thread John Hunter
On Fri, Mar 21, 2008 at 1:40 AM, Eric Firing [EMAIL PROTECTED] wrote:

   Out of interest, how does one tell MPL to start a new figure and forget
   everything that's gone before?

  You can minimize the amount of package and module-level state
  information by using the oo interface: see examples/agg_oo.py.  If you
  change any rcParams dictionary entries, typically using the rc function,
  then you can restore the dictionary to its default condition with the
  rcdefaults() function.

I think it is comparatively rare to modify rc params within code (and
never necessary since you can achieve the same by setting properties
directly using the API) so if the rc params are the only global
information we are using (and I am not aware of other problems off the
top of my head but you might be well served to post to the antigrain
mailing list to see if agg is thread safe) it shouldn't pose a serious
problem.

JDH

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib threadsafe?

2008-03-20 Thread Chris Withers
Michael Droettboom wrote:
 At least the Agg backend *looks* to be reasonably threadsafe -- there 
 are no obvious gotchas like global variables etc.  Note, though, that 
 multithreading may not gain much in the way of performance since the 
 global interpreter lock is never released around long-running C blocks.

It's not performance I'm looking for, it's making sure that MPL apps 
served from multi-threaded wsgi servers don't screw each others charts 
up ;-)

cheers,

Chris

-- 
Simplistix - Content Management, Zope  Python Consulting
- http://www.simplistix.co.uk

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib threadsafe?

2008-03-20 Thread Chris Withers
Eric Firing wrote:
 In general, I don't think mpl is threadsafe at all; it uses global 
 variables, such as all the rc parameters, that could easily be modified 
 by one thread while being used by another. 

Yep, I guessed as much, BFL it is then ;-)

 I think that great care 
 would be needed if one wanted to have multiple threads making plots. 
 Having one plotting thread and any number of threads doing other things, 
 however, should be OK.

Out of interest, how does one tell MPL to start a new figure and forget 
everything that's gone before?

 At the very least, I think we would have to take all the global state 
 information and put it in a class instance, so there could be multiple 
 plotting machines. 

Yes.

cheers,

Chris

-- 
Simplistix - Content Management, Zope  Python Consulting
- http://www.simplistix.co.uk

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib threadsafe?

2008-03-19 Thread Michael Droettboom
Eric Firing wrote:
 In general, I don't think mpl is threadsafe at all; it uses global 
 variables, such as all the rc parameters, that could easily be 
 modified by one thread while being used by another.  I think that 
 great care would be needed if one wanted to have multiple threads 
 making plots. Having one plotting thread and any number of threads 
 doing other things, however, should be OK.
Oh yes -- I didn't think of the rcParams.

 Michael Droettboom wrote:
 At least the Agg backend *looks* to be reasonably threadsafe -- there 
 are no obvious gotchas like global variables etc.  Note, though, that 
 multithreading may not gain much in the way of performance since the 
 global interpreter lock is never released around long-running C blocks.

 Possibly this could be changed.  The danger would be accidentally 
 modifying or deleting an array that is being used by C extension code.
Modifying may be problematic, but deleting would not be likely -- the C 
function holds a reference to each of the arrays as they are using them.


 However, I can't speak about this from any experience -- so, maybe it 
 needs some trying.  Any patches to help with thread safety and 
 performance are of course welcome ;)

 At the very least, I think we would have to take all the global state 
 information and put it in a class instance, so there could be multiple 
 plotting machines.  Pyplot would then instantiate and use one of 
 these; the OO API would allow one to instantiate any number of them.  
 I have not thought about how easy or hard this would be.
Ditto that.  Having just come back from PyCon, I'll parrot the standard 
Python answer to this question which is: Don't use threads, use 
multiple processes, which would seem to solve all these issues -- but, 
I understand that it not always the best solution.

Mike

 Eric


 Cheers,
 Mike

 Chris Withers wrote:
 Hi All,

 I'm wondering what work people have done with matplotlib in 
 multi-threaded environments such as your average python web framework.

 Is matplotlib threadsafe?

 How have people gone about safely using it in a multi-threaded 
 environment?

 cheers,

 Chris

   


 - 

 This SF.net email is sponsored by: Microsoft
 Defy all challenges. Microsoft(R) Visual Studio 2008.
 http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib threadsafe?

2008-03-18 Thread Michael Droettboom
At least the Agg backend *looks* to be reasonably threadsafe -- there 
are no obvious gotchas like global variables etc.  Note, though, that 
multithreading may not gain much in the way of performance since the 
global interpreter lock is never released around long-running C blocks.

However, I can't speak about this from any experience -- so, maybe it 
needs some trying.  Any patches to help with thread safety and 
performance are of course welcome ;)

Cheers,
Mike

Chris Withers wrote:
 Hi All,

 I'm wondering what work people have done with matplotlib in 
 multi-threaded environments such as your average python web framework.

 Is matplotlib threadsafe?

 How have people gone about safely using it in a multi-threaded environment?

 cheers,

 Chris

   


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib threadsafe?

2008-03-18 Thread Eric Firing
In general, I don't think mpl is threadsafe at all; it uses global 
variables, such as all the rc parameters, that could easily be modified 
by one thread while being used by another.  I think that great care 
would be needed if one wanted to have multiple threads making plots. 
Having one plotting thread and any number of threads doing other things, 
however, should be OK.

Michael Droettboom wrote:
 At least the Agg backend *looks* to be reasonably threadsafe -- there 
 are no obvious gotchas like global variables etc.  Note, though, that 
 multithreading may not gain much in the way of performance since the 
 global interpreter lock is never released around long-running C blocks.

Possibly this could be changed.  The danger would be accidentally 
modifying or deleting an array that is being used by C extension code.

 
 However, I can't speak about this from any experience -- so, maybe it 
 needs some trying.  Any patches to help with thread safety and 
 performance are of course welcome ;)

At the very least, I think we would have to take all the global state 
information and put it in a class instance, so there could be multiple 
plotting machines.  Pyplot would then instantiate and use one of these; 
the OO API would allow one to instantiate any number of them.  I have 
not thought about how easy or hard this would be.

Eric

 
 Cheers,
 Mike
 
 Chris Withers wrote:
 Hi All,

 I'm wondering what work people have done with matplotlib in 
 multi-threaded environments such as your average python web framework.

 Is matplotlib threadsafe?

 How have people gone about safely using it in a multi-threaded environment?

 cheers,

 Chris

   
 
 
 -
 This SF.net email is sponsored by: Microsoft
 Defy all challenges. Microsoft(R) Visual Studio 2008.
 http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users