python-irclib and threading

2010-10-12 Thread Robin Krahl
Hi folks,

I’m writing a program with a component that has to connect to IRC and
call a callback function in case of a message.  I tried using
python-irclib for doing this, and executing the code in the main thread
worked fine.  When I moved the code part into the run method of a
threading.Thread class, it doesn’t work anymore.  The code is:

# …
def run(self):
# …
self._lg.debug('AAA')
irc = irclib.IRC()
server = irc.server()
server.connect('irc.freenode.net', 6667, 'rcc')
self._lg.debug('BBB')
irc.process_forever()
self._lg.debug('CCC')
# …
# …

(self._lg = logging.getLogger(…))

Now, the connect method does not return.  That means that ‘AAA’ is
logged while ‘BBB’ and ‘CCC’ are not displayed (yes, I waited long
enough).

My guess was that the problem is that I have to call the connect()
method from the main thread.  Is this right?  If yes, what can I do
about it?  If no, do you have an idea what’s the problem?

Best regards,
Robin

-- 
Robin Krahl || ireas
  http://robin-krahl.de
  m...@robin-krahl.de



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Executing untrusted scripts in a sandboxed environment

2012-10-05 Thread Robin Krahl
Hi all,

I need to execute untrusted scripts in my Python application. To avoid security 
issues, I want to use a sandboxed environment. This means that the script 
authors have no access to the file system. They may only access objects, 
modules and classes that are "flagged" or "approved" for scripting.

I read that I will not be able to do this with Python scripts. (See 
SandboxedPython page in the Python wiki [0] and several SE.com questions, e. g. 
[1].) So my question is: What is the best way to "embed" a script engine in a 
sandboxed environment that has access to the Python modules and classes that I 
provide?

Thanks for your help.

Best regards,
Robin

[0] http://wiki.python.org/moin/SandboxedPython
[1] 
http://stackoverflow.com/questions/3068139/how-can-i-sandbox-python-in-pure-python
-- 
http://mail.python.org/mailman/listinfo/python-list