X-1.0rc2: IDE: using MongoDB - pymongo: connections not closed

Bug #825273 reported by WD+WD
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
In Progress
Low
RaiMan

Bug Description

Hi. I tried to write a sikuli script that takes & saves data to mongodb using pymongo.
But sikuli raises non-blocking socket exception when pymongo trying to process data, especially if I call "save" method.
I tried to fix this by connecting & disconnecting every time then I needed to get/change data.
Also, I noticed that sikuli doesn't close the connections to mongo ( even if i call disconnect() method ), so after few minutes of working the amount of unclosed connections growes up very fast. MongoDB starts to deny all incoming connections and freezes. When I close Sikuli IDE, all those connections are shutting down, so MongoDB starts work correctly.

Tags: build jython
Revision history for this message
RaiMan (raimund-hocke) wrote :

Running scripts in the Sikuli IDE includes the "feature", that no finalize actions at script end are taken (as is the fact, when running a script in the Python/Jython interpreter). This saves the startup time of 3 - 5 seconds for running a script outside the IDE.

So you should run your scripts from command line.

You might try, to use Jython 2.5.2 (Sikuli is bundled with 2.5.1) and see wether this changes the situation.

Generally: this is not a Sikuli problem - it is related to Jython/MogngoDB/pymongo

summary: - pymongo fail
+ X-1.0rc2: IDE: using MongoDB - pymongo: connections not closed
Revision history for this message
WD+WD (wd+wd) wrote :

May I disagree with you in some points? I created small and simple test script that only connects to mongo & closes this connection ( ~ 3 lines of code ) using pymongo driver.
It works great in the shell, but the same script doesn't close that connection in Sikuli. So it shows that this problem is not related to MongoDB or PyMongo driver, but to Jython/Sikuli.

I tried to launch Interactive Sikuli Jython Session from command line on Windows7 to test my script without Sikuli IDE and got an error. ( "Can't find dependent libraries" ). All paths are configured correctly. It tries to find file VisionProxy.dll where it is, shows correct path, but anyway fails.

Revision history for this message
RaiMan (raimund-hocke) wrote :

No need to disagree ;-)

I admitted, that this might make problems, when running these scripts in the IDE. So the recommendation is, to us any of the available command line versions.

There is already a request to implement some finalization/reset in the IDE (e.g. to be be able to redo an import, ...), but according to the developers not so easy and low priority.

-- Interactive Sikuli
I have:
Sikuli in: c:\Program Files\Sikuli X

system path added: c:\Program Files\Sikuli X\libs;c:\Program Files\Java\jre6\bin

running from command line:
java -jar "c:\Program Files\Sikuli X\sikuli-script.jar" -i

non problems on my Win7-32.

Revision history for this message
WD+WD (wd+wd) wrote :

I added system paths as you have and successfully ran a command line version. It still doesn't disconnect by instructions. Only when the script ends.
Can you please give me some information of upgrading Jython to 2.5.2, how can I do this? Are there any builds with upgraded Jython?

Revision history for this message
RaiMan (raimund-hocke) wrote :

- Jython not closing connection
What about this:
https://github.com/mongodb/mongo-python-driver/pull/14

- using Jython 2.5.2

3 possibilities:

--- complex: building Sikuli from source integrating python 2.5.2 (I did it for Mac, works)

--- medium: unjar sikuli-script.jar, replace jython.jar and Lib directory, rejar
--- easy: use Jython directly to run the contained .py in a .sikuli:
- use the environment variables CLASSPATH and JYTHONPATH
- set CLASSPATH=absolute-path-to-sikuli-script.jar (wherever it might be stored, does not matter where)
- set JYTHONPATH=absolute-path-to-Jython\Lib;absolute-path-to-Jython\sikuli-script.jar\Lib
- run the Sikuli script using the jython.bat path-to-script-folder\scriptname.py
- you have to somehow set the image path
(see: https://answers.launchpad.net/sikuli/+question/141302)

 (see:

Revision history for this message
RaiMan (raimund-hocke) wrote :

using Jython 2.5.3 now

Changed in sikuli:
status: New → Won't Fix
assignee: nobody → RaiMan (raimund-hocke)
milestone: none → x1.0
RaiMan (raimund-hocke)
tags: added: jython
removed: pymongo
RaiMan (raimund-hocke)
Changed in sikuli:
status: Won't Fix → In Progress
RaiMan (raimund-hocke)
tags: added: build
Changed in sikuli:
importance: Undecided → Low
milestone: x1.0 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.