Python, GTK and background threads

OK, I'm still new to python (but my teeth on COBOL a long long time ago), and whilst I can usually battle through existing scripts and figure out what's going on, I'm trying to add functionality to one of my own and no idea how to do it.
I have a python script that launches an external process (os.popen) and then opens a gtk window. The gtk works just fine and does what it's supposed to. However, I want to add a thread that will check whether or now the external program is running and if it's finished, automatically destroy the gtk window and exit the script. However, to get the gtk window I obviously have to call gtk.main, which prevents me from launching my own loop testing the other program.
incidentally, my test is based on
child = os.popen("ExternalProgram")
if child.poll() == None:
And I'm not even sure that's the correct way to test (haven't been able to even start testing yet) so perhaps if someone could give me a heads up on that, too
Any idea?
TIA

Here I am
"os.popen" and related functions have been superseded by the "subprocess" module. Use "subprocess.Popen" to spawn processes.
Wrap the invocation of the background task in a separate class – let's call it "BackgroundWorker" for now – that spawns a background thread which in turn executes the process via "subprocess.call()" and emits a "finished" signal when the process terminated. Create an instance of this class in In "MyWindow.__init__()" (where "MyWindow" is derived from "Gtk.Window") and connect the "BackgroundWorker.finished" signal to a callback which closes the window. In the entry point of your script create an instance of "MyWindow", show it and start the Gtk main loop.
Before that, read the documentation of Gtk and look for a class that wraps background processes, like "QProcess" does in Qt. I don't know if such a class exists in Gtk but if it does it'll significantly ease working with subprocesses in a GUI.
Last but not least a general and very important note concerning threads and GUIs: Do never access any GUI element directly from background thread!
Last edited by lunar (2012-05-26 17:11:25)

Similar Messages

  • How do you monitor a background thread and update the GUI

    Hello,
    I have a thread which makes its output available on PipedInputStreams. I should like to have other threads monitor the input streams and update a JTextArea embedded in a JScrollPane using the append() method.
    According to the Swing tutorial, the JTextArea must be updated on the Event Dispatch Thread. When I use SwingUtilities.invokeLater () to run my monitor threads, the component is not redrawn until the thread exits, so you don't see the progression. If I add a paint () method, the output is choppy and the scrollbar doesn't appear until the thread exits.
    Ironically, if I create and start new threads instead of using invokeLater(), I get the desired result.
    What is the correct architecture to accomplish my goal without violating Swing rules?
    Thanks,
    Brad
    Code follows:
    import java.lang.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;
    import java.awt.event.*;
    public class SystemCommand implements Runnable
         private String[] command;
         private PipedOutputStream pipeout;
         private PipedOutputStream pipeerr;
         public SystemCommand ( String[] cmd )
              command = cmd;
              pipeout = null;
              pipeerr = null;
         public void run ()
              exec ();
         public void exec ()
              // --- Local class to redirect the process input stream to a piped output stream
              class OutputMonitor implements Runnable
                   InputStream is;
                   PipedOutputStream pout;
                   public OutputMonitor ( InputStream i, PipedOutputStream p )
                        is = i;
                        pout = p;
                   public void run ()
                        try
                             int inputChar;
                             for ( ;; )
                                  inputChar = is.read();
                                  if ( inputChar == -1 ) { break; }
                                  if ( pout == null )
                                       System.out.write ( inputChar );
                                  else
                                       pout.write ( inputChar );
                             if ( pout != null )
                                  pout.flush ();
                                  pout.close ();
                             else
                                  System.out.flush();
                        catch ( Exception e ) { e.printStackTrace (); }     
              try
                   Runtime r = Runtime.getRuntime ();
                   Process p = r.exec ( command );
                   OutputMonitor out = new OutputMonitor ( p.getInputStream (), pipeout );
                   OutputMonitor err = new OutputMonitor ( p.getErrorStream (), pipeerr );
                   Thread t1 = new Thread ( out );
                   Thread t2 = new Thread ( err );
                   t1.start ();
                   t2.start ();
                   //p.waitFor ();
              catch ( Exception e ) { e.printStackTrace (); }
         public PipedInputStream getInputStream () throws IOException
              pipeout = new PipedOutputStream ();
              return new PipedInputStream ( pipeout );
         public PipedInputStream getErrorStream () throws IOException
              pipeerr = new PipedOutputStream ();
              return new PipedInputStream ( pipeerr );
         public void execInThread ()
              Thread t = new Thread ( this );
              t.start ();
         public static JPanel getContentPane ( JTextArea ta )
              JPanel p = new JPanel ( new BorderLayout () );
              JPanel bottom = new JPanel ( new FlowLayout () );
              JButton button = new JButton ( "Exit" );
              button.addActionListener ( new ActionListener ( )
                                       public void actionPerformed ( ActionEvent e )
                                            System.exit ( 0 );
              bottom.add ( button );
              p.add ( new JScrollPane ( ta ), BorderLayout.CENTER );
              p.add ( bottom, BorderLayout.SOUTH );
              p.setPreferredSize ( new Dimension ( 640,480 ) );
              return p;
         public static void main ( String[] argv )
              // --- Local class to run on the event dispatch thread to update the Swing GUI
              class GuiUpdate implements Runnable
                   private PipedInputStream pin;
                   private PipedInputStream perr;
                   private JTextArea outputArea;
                   GuiUpdate ( JTextArea textArea, PipedInputStream in )
                        pin = in;
                        outputArea = textArea;
                   public void run ()
                        try
                             // --- Reads whole file before displaying...takes too long
                             //outputArea.read ( new InputStreamReader ( pin ), null );
                             BufferedReader r = new BufferedReader ( new InputStreamReader ( pin ) );
                             String line;
                             for ( ;; )
                                  line = r.readLine ();
                                  if ( line == null ) { break; }
                                  outputArea.append ( line + "\n" );
                                  // outputArea.paint ( outputArea.getGraphics());
                        catch ( Exception e ) { e.printStackTrace (); }
              // --- Create and realize the GUI
              JFrame f = new JFrame ( "Output Capture" );
              f.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
              JTextArea textOutput = new JTextArea ();
              f.getContentPane().add ( getContentPane ( textOutput ) );
              f.pack();
              f.show ();
              // --- Start the command and capture the output in the scrollable text area
              try
                   // --- Create the command and setup the pipes
                   SystemCommand s = new SystemCommand ( argv );
                   PipedInputStream stdout_pipe = s.getInputStream ();
                   PipedInputStream stderr_pipe = s.getErrorStream ();
                   // --- Launch
                   s.execInThread ( );
                   //s.exec ();
                   // --- Watch the results
                   SwingUtilities.invokeLater ( new GuiUpdate ( textOutput, stdout_pipe ) );
                   SwingUtilities.invokeLater ( new GuiUpdate ( textOutput, stderr_pipe ) );
                   //Thread t1 = new Thread ( new GuiUpdate ( textOutput, stdout_pipe ) );
                   //Thread t2 = new Thread ( new GuiUpdate ( textOutput, stderr_pipe ) );
                   //t1.start ();
                   //t2.start ();
              catch ( Exception e ) { e.printStackTrace (); }
              

    Thanks for pointing out the SwingWorker class. I didn't use it directly, but the documentation gave me some ideas that helped.
    Instead of using invokeLater on the long-running pipe-reader object, I run it on a normal thread and let it consume the output from the background thread that is running the system command. Inside the reader thread I create a tiny Runnable object for each line that is read from the pipe, and queue that object with invokeLater (), then yield() the reader thread.
    Seems like a lot of runnable objects, but it works ok.

  • [SOLVED]Python learning and gtk+ try

    Hi,
    I wanna enjoy with python gtk+ toolkit.
    I try run this code:
    #!/usr/bin/python
    from gi.repository import Gtk
    Gtk.init(None)
    Hello=Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.CLOSE, "Hello world!")
    Hello.format_secondary_text("This is an example dialog.")
    Hello.run()
    from wiki and I get errors:
    Traceback (most recent call last):
    File "./gtk1.py", line 2, in <module>
    from gi.repository import Gtk
    File "/usr/lib/python3.2/site-packages/gi/repository/__init__.py", line 25, in <module>
    from ..importer import DynamicImporter
    File "/usr/lib/python3.2/site-packages/gi/importer.py", line 24, in <module>
    import logging
    File "/usr/lib/python3.2/logging/__init__.py", line 27, in <module>
    from string import Template
    ImportError: cannot import name Template
    I'm little n00b in python, and I need help If it's important I am using geany.
    anyway this code in c++ works pretty good.
    Last edited by xorgx3 (2012-05-23 19:37:52)

    I'm a lot n00b in python.  That said, my suggestion would be to try the command that failed (from string import Template) directly in the python interpreter.  If you get the error there, relaunch the interpreter with extra verbosity and run the command again; maybe it will help you figure out what's wrong.

  • The background thread running lazy writer encountered an I/O error

    Hi I have a test server which has thrown the following error
    File system error: A system error occurred while attempting to read or write to a file store. The system might be under memory pressure or low on disk space. Physical file: \\?\F:\MSAS11.DEPLOYAS\OLAP\Data\Prod_KCube.0.db\DIM Flags And Types.0.dim\3.Flag
    Types Key.khstore. Logical file: . GetLastError code: 8. File system error: The background thread running lazy writer encountered an I/O error. Physical file: \\?\F:\MSAS11.DEPLOYAS\OLAP\Data\Prod_KCube.0.db\DIM Flags And Types.0.dim\3.Flag Types Key.khstore.
    Logical file: . Errors in the OLAP storage engine: An error occurred while processing the 'Facts' partition of the 'Main Facts' measure group for the 'Prod_Cube' cube from the Prod_KCube database.
    The cube sits on a not very well maintained server which is used by various users (it is a test server) with the following specs
    Intel(R) Xenon(R) CPU x5690 @3.47GHz
    24GB Ram
    64 Bit operating system.
    The Cube data and logs are on separate drives and have plenty data but the C drive (where SQL Server is installed) only has3.5Gb of space left.
    It's a fairly big cube and I've managed to get it running by processing dimensions and facts bit by bit but errors when processed all together.
    What could be causing the errors above?

    Hi aivoryuk,
    According to your description, you get the lazy writing error when processing partitions. Right?
    In this scenario, the issue may cause by low memory for SSAS and lack of disk space. Please consider configure
    Server Properties (Memory Page) and increase
    memory setting for SSAS. If the .cub file is located in C drive, please reserve more disk space.
    Please refer to a similar thread below:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/21bf84c5-f89a-464a-a5f1-2649fae5eb1e/while-processing-large-cubes-various-file-system-errors-the-background-thread-running-lazy-writer?forum=sqlanalysisservices
    Best Regards,
    Simon Hou
    TechNet Community Support

  • Background threading + batch file processing

    Hello,
    I have 2 issues in the same project.
    Issue 1:
    I have a project accessing the Object API. I've created a DLL assembly using VB.NET. This assembly is instatiated from a VB form and one of the functions is called using a background thread worker from the from. This code runs normally when NOT running in the background worker. However running in the background worker throws an exception. I have attached some sample code. To test it would will need to create the an interop for the Object API compenent for GroupWise. It ws too big to attach here. My apologizes for that.
    Issue 2:
    In the same project using the same assembly, I am calling the application from a batch file. Again the code runs normally from the debugger, but running the batch file throws an exception instantiating an instance of the Application object.
    If anyone can shine some light on these issues that would be great.
    Thanks
    Tim

    Hiroto, no I didn't have it checked. I don't know why I was able to get as far as I did but enabling access for assistive devices didn't change anything. I am able to emulate /almost/ any keystroke, except the up arrow, which normally allows me to move up in the "file type" selector button. The script below is ... functional ... except that it forces me to save each file as a 58MB uncompressed .tiff, and it refuses to respond to the "close front window" or 'keystroke "W" using command down' scripts. Getting through 300+ files this way will eat up my memory and hard drive in a matter of minutes. I suppose I could '$sh kill ####' from terminal if I could find the window process, but this is getting really hoaky!
    THIS SCRIPT OPENS AND SAVES FILES, BUT DISALLOWS ANY TYPE SELECTION OR CLEANUP
    set sFiles to (choose file with multiple selections allowed without invisibles)
    repeat with aFile in sFiles
    tell application "Preview" to run
    tell application "System Events" to tell process "Preview"
    tell application "Preview"
    activate
    open aFile
    delay 8
    tell application "System Events"
    keystroke "S" using {command down, shift down}
    delay 2 -- opens save as sheet
    repeat 7 times
    keystroke tab -- tab down to file selector (works fine)
    end repeat
    click down -- select button (doesn't do anything)
    delay 1
    keystroke up -- open file button menu (doesn't work)
    keystroke up -- select next menu item above (doesn't work)
    keystroke return -- shortcut to "save" button
    delay 10 -- wait for save
    keystroke "W" using command down -- close current window (doesn't work)
    end tell
    end tell
    end tell
    end repeat

  • Updating the GUI from a background Thread: Platform.Runlater() Vs Tasks

    Hi Everyone,
    Hereby I would like to ask if anyone can enlighten me on the best practice for concurency with JAVAFX2. More precisely, if one has to update a Gui from a background Thread what should be the appropriate approach.
    I further explain my though:
    I have window with a text box in it and i receive some message on my network on the background, hence i want to update the scrolling textbox of my window with the incoming message. In that scenario what is the best appraoch.
    1- Shall i implement my my message receiver as thread in which i would then use a platform.RunLater() ?
    2- Or shall i use a Task ? In that case, which public property of the task shall take the message that i receive ? Are property of the task only those already defined, or any public property defined in subclass can be used to be binded in the graphical thread ?
    In general i would like to understand, what is the logic behind each method ?
    My understanding here, is that task property are only meant to update the gui with respect to the status of the task. However updating the Gui about information of change that have occured on the data model, requires Platform.RunLater to be used.
    Edited by: 987669 on Feb 12, 2013 12:12 PM

    Shall i implement my my message receiver as thread in which i would then use a platform.RunLater() ?Yes.
    Or shall i use a Task ?No.
    what is the logic behind each method?A general rule of thumb:
    a) If the operation is initiated by the client (e.g. fetch data from a server), use a Task for a one-off process (or a Service for a repeated process):
    - the extra facilities of a Task such as easier implementation of thread safety, work done and message properties, etc. are usually needed in this case.
    b) If the operation is initiated by the server (e.g. push data to the client), use Platform.runLater:
    - spin up a standard thread to listen for data (your network communication library will probably do this anyway) and to communicate results back to your UI.
    - likely you don't need the additional overhead and facilities of a Task in this case.
    Tasks and Platform.runLater are not mutually exclusive. For example if you want to update your GUI based on a partial result from an in-process task, then you can create the task and in the Task's call method, use a Platform.runLater to update the GUI as the task is executing. That's kind of a more advanced use-case and is documented in the Task documentation as "A Task Which Returns Partial Results" http://docs.oracle.com/javafx/2/api/javafx/concurrent/Task.html

  • Combining the fixed and cached thread pools

    Is there a way to 'combine' the behavior of cached and fixed thread pools ? I have a requirement where
    - at startup, I need to execute a fixed number of short-lived tasks at the background
    - after startup, on demand, I need to run one short-lived task at a time
    If I use a fixed thread pool for my startup processing, it creates the fixed number of threads to process the tasks. But subsequently, those many threads are not required since my task submission is going to be one at a time. The remaining (n-1) threads therefore are really sitting idle & useless.
    If I use a cached thread pool, then I cannot constrain the number of threads to run at startup (since it creates one for each task). Though it ends up taking those threads out after they are idle for a fixed period. But I'm worried that it might create many threads and possibly slowing down the startup ?
    Is there a way to create a pool with a fixed number of threads but 'remove' a set of threads when they are idle ?
    TIA

    v_bala wrote:
    Thanks. The SynchronousQueue worked as expected. But I tried a LinkedBlockingQueue with size 1 hoping that would cause the second task submission to cause a new thread creation. It didn't. Instead it queues up the request (maybe the doc in ThreadPoolExecutor says that when it mentions "If corePoolSize or more threads are running, the Executor always prefers queuing a request rather than adding a new thread"). I suppose if I were to try another it would create another thread ? (I was testing with only two tasks - the first one ended up creating a thread for the task and the next got queued since the queue capacity is 1)yes, the TPE will not start adding threads until the queue starts rejecting them. kind of odd in my opinion, but that's how it works.
    Btw, that was an interesting idea to add a task that scale the core pool number down ! Currently it comes back down to just the one thread (my core pool size is one) after the idle timeout but your idea may give me a slightly better response since it will scale down the core pool size quicker....I suppose if there was a task submission before that idle time there maybe a performance hit (but I don't anticipate that in my case )?actually, that won't scale things down any faster. changing the core pool size will not ditch the other threads immediately, they will still stick around until they idle timeout. changing the core pool size allows you to not worry about the queue implementation (the first solution). you can set the initial core pool size to your "max" size on startup, then drop it down for the normal processing, all the while using a linkedblockingqueue of unlimited size.

  • Exporting a jpeg in background thread: ID CS5

    Hi All,
    I am working on a plugin for CS5 and CS5.5, My plugin requirement is that it should export a document to pdf and jpeg format on background thread, On looking into CHM I found that there is a article "Asynchronous exports, Multithreading" which says that only IDML and pdf  are the two formats that can be export in background thread.
    Is is possible eto export a document in JPEG format on bakground thread? if yes then should I need to follow aproach mentioned in chm article "Asynchronous exports, Multithreading" or there is some other way to do it.
    Please help me to find out a way using which I can achieve this.
    Thanks
    Alam

    topfuelmaniac,
    I believe the issue will be solved if both the artwork and the Artboard are aligned with the pixel grid.
    The Transform Palette has the option Align to  Pixel Grid.
    The artwork may be off, and if so, it is better to align it properly than to snip off parts to fit the size it should have from the start.
    If you have portions of the artwork, such as parts of strokes, outside the Bounding Box, you may have to rethink. You can turn on Use Preview Bounds in the preferences to see the real size to be exported.

  • How to draw uiview in background thread.

    hi all, i have a big map in my iphone application, i need to dynamic load the map when user move the map. in this case, i need to draw the new loaded part before user can see it, my question is how to draw those new loaded part in background thread?
    i tried to create a thread, and in this thread call [xxview setNeedsDisplay], but this thread closed before the drawRect is finished.
    thanks.

    You can also load the VI through the VI Server. Since the data flow is avoided, and the VI is essentially loaded as external code, it gets it's own thread as far as I know.
    When doing this, setting the Property "Wait until finished" to false is quite useful too.
    Hope this helps.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
    Attachments:
    Vi server.png ‏16 KB

  • I'm using Photoshop Elements 12 on Windows 8.1.  When I go into the Expert Edit Mode the toolbar available appears in one single column and misses off several tools including foreground and background colour.  How can I restore the original toolbar?

    I'm using Photoshop Elements 12 on Windows 8.1.  When I go into the Expert Edit Mode the toolbar available appears in one single column and misses off several tools including foreground and background colour.  How can I restore the original toolbar?

    Thanks for your help - your suggestion worked beautifully.Dennis Hood
          From: 99jon <[email protected]>
    To: Dennis Hood <[email protected]>
    Sent: Thursday, 15 January 2015, 15:20
    Subject:  I'm using Photoshop Elements 12 on Windows 8.1.  When I go into the Expert Edit Mode the toolbar available appears in one single column and misses off several tools including foreground and background colour.  How can I restore the original toolbar?
    I'm using Photoshop Elements 12 on Windows 8.1.  When I go into the Expert Edit Mode the toolbar available appears in one single column and misses off several tools including foreground and background colour.  How can I restore the original toolbar?
    created by 99jon in Photoshop Elements - View the full discussionTry re-setting the prefs.Go to: Edit >> Preferences >> General (Photoshop Elements menu on Mac)Click the button Reset Preferences on next Launch If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/7099161#7099161 and clicking ‘Correct’ below the answer Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/7099161#7099161 To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"  Start a new discussion in Photoshop Elements by email or at Adobe Community For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

  • Packaging concept for GUI and Background, using SwingWorker

    How to set up the following structure, in order to meet the requirements of SwingWorker (doInBackground, publish, process):
    1. There is a class SGui - contained in a package of Swing GUI methods SGui, located in package ...sgui - which will
    - start a background thread, by using SwingWorker, which does some complex logics (the methods from class SSolv, see item 2)
    - it passes initial data to that background process, which have been entered into the GUI
    - displays the intermediate results from the background threat
    2. There is another class SSolv, in package ...ssolv, which contains some complex logics, and should deliver intermediate results to be displayed by the GUI
    From all the information from tutorial etc., I put up a structure like this, for SSolv:
    package ...ssolv;
    class SSolv {
    void senderMethod {
    publish (ComData...)   // should transfer the data to the EDT
    : class ComData {
    //  ... puts up the objects for transferring the data to the GUI, by method publish
    }All the rest of Swing methods goes to package SGui.
    This stub already shows the issue, which comes from structuring the application in two (or even more) packages : compiling package SSolv produces the error publish(V...)
    has protected access in javax.swing.SwingWorker ! I understand that this protected method could only be used in this context, after instancing a subclass of SwingWorker,
    - however I thought it would most senseful to get the "sender" (+publish+), and the "contents" (+ComData+) to the package, where the data will be produced.
    This is evidently in contradiction to the requirement, that publish - as a protected method of SwingWorker - should be defined in the SGui class, as it has to apply the (overriden) methods process (including get), done etc.
    With my application, the SGui class will be compiled later ! So I had to reference a method from SGui that is not known during compiling of SSolv !
    Unfortunately, all the examples shown in the tutorials (as far as I can already know them...) only use one package; so all the classes are compiled from one file, and they will not get this dilemma.
    Please give me some idea, how I will have to restructure / workaround / use advanced methods, to solve this ?
    Edited by: GW.G on 16.07.2010 17:27

    Bad news: I did some homework, but I didn't get it working...
    One reason may be, that your demo doesn't cover my reqs. exactly, regarding implementation of MySwingWorker, because my SSolv - which does all the processing - has to be in the doInBackground() method, and the 'senderMethod' (called dumpExFlags in my SSolv.java) is running integrated from within, because the application SSolv decides, when we have data ready for publishing. See code below...
    Secondly, I really did not get the point with your design, especially with the following segment from MySwingWorker, regarding the use of the private objects sgui and ssolv, and the mechanism of the constructor ?
    import yr2010.m07.d.ssolv.ComData;
    import yr2010.m07.d.ssolv.SSolv;
    public class MySwingWorker extends SwingWorker<Void, ComData> {
       private SGui sgui;
       private SSolv ssolv = new SSolv(this);
       public MySwingWorker(SGui sgui) {
          this.sgui = sgui;
       @Override
       protected Void doInBackground() throws Exception {
          ssolv.senderMethod();
          return null;
       }{code}
    By the way, I analysed the java files with PMD, and didn't find any relevant
    hints why things should not work like that.
    Another tricky detail: the compiler (as well as PMD) reports, that method 'publish' does not 'override', except calling the super method, but your example works !?
    Finally, to my knowledge any type that is overriden, should have his own @Override 'tag'. So did you purposefully omit that in your design ?
    Worst of all, I just ran into the problem that the compiler will not
    recognize all the the variables and methods I imported to the
    DoSolver(SwingWorker subclass). (This may be an issue from my 'bottom
    up' design of my 1000 lines of this first Java example I produced), but:
    I don't see why, in this case, javac ignores all the imports from other
    packages, and reports 'cannot find symbol' on ANYTHING ... ? This puts my debugging efforts on the major problem to halt ...
    {code}
    package s3forum.sgui;
    import javax.swing.;
    import java.util.;
    import s3forum.ssolv.SSolv;
    import s3forum.ssolv.ComData;
    import s3forum.sgui.SGui;
    public class DoSolver extends SwingWorker< Void, ComData > { // SSolv definiert Datenformat
      // DoSolver() - shouldn't be necessary. implicitly defined by instancing with
      // DoSolver dSol = new DoSolver() - should get the overriden methods ready for use
    // ========== Background process, will start when instancing DoSolver
    @Override
    protected Void doInBackground() {
      SSolv slv=new SSolv(vArr); // Instance of solver. vArr=start-values from SGui
    return null;
    //============ Gets data from SSolv coninuously
    @Override
    public void process (java.util.List cDList) {
      if (cDList.size() > 1) { //### Prelim: ignore multiple datasets!
        System.out.println(" ### Multiple values !! ### ");
      ComData cD = cDList.get( cDList.size()-1 );
      dispMLabel (cD.getX, cD.getY, cD.getD);
      if (cD.getIS) {
        dispMText (cD.getX, cD.getY, cD.getD);
    } //Process
    //=========== Postprocessing after SSolver finishes
    @Override
    public void done() {
         // Message
      dispGuiMsg ("Solver ist beendet. FERTIG dr&uuml;cken zum Beenden >");
        // modify button, forcing System.exit()
      fertigB.setActionCommand("fertigWaitEnd");
      fertigB.setEnabled(true);
    //=================== publish, should override method from SwingWorker
    @Override
    public void publish( ComData cd ) {
      super.publish(cd);
    } // Class DoSolver
    {code}
    Could you please further comment on this ? Thank you !
    Edited by: GW.G on 20.07.2010 12:46
    Edited by: GW.G on 20.07.2010 12:48                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Start python applications in background

    Hi everyone,
    I was trying to launch sonata with autostart.sh in openbox, when I realized that every python application (and sonata among them) "dies" when the shell is closed (autostart.sh is a bash script), even if '&' is used to run the command in background.
    So, is there a workaround to have python application backgrounded when launched from terminals or bash scripts?
    Thanks!

    AsA wrote:
    Ok, now it's solved, sonata could be run simply with "sonata &", the problem I had was caused by an error I had done previously.
    But still remains a doubt. Why running in a terminal emulator "(sonata &)" makes sonata backgrounded (can close the terminal), while typing "sonata &" (without brackets) simply don't?.
    I didn't know of any magical power of round brackets.
    hmm... does sonata& and sonata & react differently?

  • Main Thread is Foreground thread or Background thread ?

    The .NET Framework defines two types of threads: foreground and background.
    By default when we create a thread, it is a foreground thread, but we can change it to a background
    All processes have at least one thread of execution, which is usually called the main thread because it is the one that is executed when your program begins.
    Is this main thread is back ground or foreground thread.
    Regards
    krrishbiju

    The difference between a foreground thread/process is the priority and the parent/child ordering.  A main process/thread is the parent with higher priority while the background process/thread is the child with lower priority.  There is very little
    different between a process and a thread.  A class object is also a process.
    Processes run until a blocking method stops the execution (waits for an event before continuing) or when the operating system periodically performs a task switch to allow all processes a chance to run.  Processes with higher priority are allowed to
    run more often than processes with lower priority.
    jdweng

  • CC v5.2 - Multiple background threads

    Right now we are limited to running 3 background jobs at any given time due to a background thread configuration option in "Performance Tuning" that is set at 3 which the SAP default value.
    We need to run a slew of reports right now to prepare for our year-end audit, and are looking to increase the value from 3 to 10. If we make that configuration change (for # of background threads), what are the negative impacts if any?
    Thanks ahead of time for your assistance
    RJ

    Dear Roddy,
    As per the SAP standards for BG jobs, 4GB of RAM is sufficient for 3 jobs working together at the same time.
    Now you can surely increase the number of threads and the only impact you can see for this is that effectively, the time for each job will increase a bit as each job will consume equal resources while running.
    Thus you can say:
    Time taken for job to complete is directly proportional to RAM and also to the number of threads.
    Regards,
    Hersh.

  • Memory leaks and multi threading issues in managed client.

    In our company we use a lot of Oracle, and after the release of the managed provider we migrated all applications to it. First the  things were very impressive : the new client was faster, but after some days applications that uses 100MB with old client goes to 1GB and up. The memory is not the only issue, we use a lot of multi threading, and we experience connection drops and not disposal, after 1 days working one of the application had over 100 sessions on the server. I think there is something wrong with connection pool and multi threading.
    Is someone experience same problems.
    Yesterday we went back with unmanaged provider. Now things are back to normal.

    connection drops: did you try to use "Validate Connection=true" parameter in your connection string?
    the new client was faster: are you sure with this statement? Even in 64bit environment? I got quite serious performance problems when running application under 64bit process: https://forums.oracle.com/thread/2595323

Maybe you are looking for