This forum has been archived. All content is frozen. Please use KDE Discuss instead.

ktorrent hangs when running scripts

Tags: None
(comma "," separated)
timmy
Registered Member
Posts
2
Karma
0

ktorrent hangs when running scripts

Sat Jul 04, 2009 8:29 pm
Hi there,

I have a problem with two scripts I'm currently working on;
I would like the first one to run periodically, so i tried using the time.sleep() function (in python), but it causes ktorrent to hang.
same thing with the second one which is supposed to send information over network, it hangs on socket.listen() while waiting for a client to connect.
Does ktorrent wait for the script to end or am I doing something wrong?
George
Moderator
Posts
5421
Karma
1
timmy wrote:Hi there,

I have a problem with two scripts I'm currently working on;
I would like the first one to run periodically, so i tried using the time.sleep() function (in python), but it causes ktorrent to hang.


Use KTScriptingPlugin.createTimer(False), this will create a Qt QTimer. (See the auto resume script for an example). Never ever sleep in a script, because the script runs in the same thread as ktorrent's main thread, this will completely block KT's main thread.

same thing with the second one which is supposed to send information over network, it hangs on socket.listen() while waiting for a client to connect.
Does ktorrent wait for the script to end or am I doing something wrong?


Same thing as above, you are using a blocking function, it will block the GUI. You have to use something non blocking.
timmy
Registered Member
Posts
2
Karma
0
George wrote:
timmy wrote:Hi there,

I have a problem with two scripts I'm currently working on;
I would like the first one to run periodically, so i tried using the time.sleep() function (in python), but it causes ktorrent to hang.


Use KTScriptingPlugin.createTimer(False), this will create a Qt QTimer. (See the auto resume script for an example). Never ever sleep in a script, because the script runs in the same thread as ktorrent's main thread, this will completely block KT's main thread.

same thing with the second one which is supposed to send information over network, it hangs on socket.listen() while waiting for a client to connect.
Does ktorrent wait for the script to end or am I doing something wrong?


Same thing as above, you are using a blocking function, it will block the GUI. You have to use something non blocking.


Works fine, thanks for the help!


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot]