how can I block all threads for a specific amount of time? (i need to
sleep whole process for testing purposes). i thought of accessing GIL
and sleep for some amount of time, but I don't know how to do this and
whether GIL is recursive.
--
http://mail.python.org/mailman/listinfo/python-list
i have a generator that raises an exception when calling next(),
however if I try to catch the exception and print the traceback i get
only the line where next() was called
while True:
try:
iterator.next()
except StopIteration:
break
except Exception, e:
traceback.print_exc()
h
On Sep 5, 1:13 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> Alexandru Mosoi wrote:
> > On Sep 5, 11:47 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> >> Alexandru Moșoi wrote:
> >> > i'm facing the following problem:
>
> >> > class Bas
On Sep 5, 11:47 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> Alexandru Moșoi wrote:
> > i'm facing the following problem:
>
> > class Base(object):
> > def __getattr__(self, attr): return lambda x: attr + '_' + x
>
> > def dec(callable):
> > return lambda *args: 'dec_' + callable(*args)
>
> > c
supposing that I have a server (an instance of SocketServer()) that
waits for a connection (ie is blocked in accept()) and in another
thread i want to stop the server, how do I do that?
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 27, 12:45 pm, Alexandru Mosoi <[EMAIL PROTECTED]> wrote:
> how is Queue intended to be used? I found the following code in python
> manual, but I don't understand how to stop consumers after all items
> have been produced. I tried different approaches but all of the
On Aug 27, 2:54 pm, Jeff <[EMAIL PROTECTED]> wrote:
> Queue raises an Empty exception when there are no items left in the
> queue. Put the q.get() call in a try block and exit in the except
> block.
Wrong. What if producer takes a long time to produce an item?
Consumers
will find the queue empty
On Aug 27, 1:06 pm, Gerhard Häring <[EMAIL PROTECTED]> wrote:
> Alexandru Mosoi wrote:
> > how is Queue intended to be used? I found the following code in python
> > manual, but I don't understand how to stop consumers after all items
> > have been produced. I tried
how is Queue intended to be used? I found the following code in python
manual, but I don't understand how to stop consumers after all items
have been produced. I tried different approaches but all of them
seemed incorrect (race, deadlock or duplicating queue functionality)
def worker():
how can i do an atomic read+increment? something like
with lock:
old = atomic_int
atomic_int += 1
but in one operation
--
http://mail.python.org/mailman/listinfo/python-list
why doesn't logging throw any exception when it should? how do I
configure logging to throw exceptions?
>>> try:
... logging.fatal('asdf %d', '123')
... except:
... print 'this line is never printed'
...
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2
i want to execute a python script using exec open('script.py'). how do
I pass arguments?
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 18, 6:02 pm, Alexandru Mosoi <[EMAIL PROTECTED]> wrote:
> how can I catch (globally) exception that were not caught in a try/
> catch block in any running thread? i had this weird case that an
> exception was raised in one thread, but nothing was displayed/logged.
I foun
On Aug 18, 6:18 pm, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Aug 18, 10:02 am, Alexandru Mosoi <[EMAIL PROTECTED]> wrote:
>
> > how can I catch (globally) exception that were not caught in a try/
> > catch block in any running thread? i had this weird case that
how can I catch (globally) exception that were not caught in a try/
catch block in any running thread? i had this weird case that an
exception was raised in one thread, but nothing was displayed/logged.
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 18, 11:34 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> >>> import sys, subprocess
> >>> subprocess.call([sys.executable, "-c", "print 'hello'"])
> hello
> 0
10x :). exactly what I was looking for.
--
http://mail.python.org/mailman/listinfo/python-list
how do I execute another python script under a different process? I
want the script to be run using the same interpretoer as the one
running current script. I tried using os.execlp but I don't know how
to get the name/path of the interpreter.
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 12, 7:46 pm, "Calvin Spealman" <[EMAIL PROTECTED]> wrote:
> The best answer is: Don't do that!
>
> That isn't how you test things. Write test scripts, probably using the
> unittest framework. You'll save yourself time and trouble having
> easily reproducible tests. Many people suggested relo
On Aug 14, 12:02 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> your use of the word "callback" is a bit unusual, and your example isn't
> valid Python code, but it looks as if functools.partial might be what
> you need:
>
> http://docs.python.org/lib/module-functools.html
my current implemen
does anyone know a nice implementation of callbacks in python? i have
issues mixing named & unamed parameters. i want build a callback over
a function such that some parameters are passed when callback is
created and the rest are passed when the function is called.
example:
callback = Callback(fun
I want to derive a base class, such that some methods are decorated.
The only thing I have in mind is:
class Base(object):
def A(self, x): pass
def B(self, y): pass
class Derived(Base):
@decorator
def A(self, x): Base.A(self, x)
Is this correct approach? How can avoid call to Base.A(...
I'm using python's interpreter's to run various commands (like a
normal shell). However if sources are modified changes are not
reflected so I have to restart interpreter. Is there any way to avoid
restarting this?
example:
import blah
blah.Blah()
# ... blah.Blah() changed
blah.Blah()
# ... new
22 matches
Mail list logo