ystems offer an asynchronous
gethostbyname, but that doesn't help users of Python's library.
Some programmers would keep around a few extra processes to
handle their hosts lookups. Fortunately, threading systems are
now much better, and should only block the thread waiting for
gethos
s are good, see:
http://www.usenix.org/events/hotos03/tech/vonbehren.html
For an example of a high-performance server that uses massive
threading, I'd nominate MySQL.
Prediction: Ten years from now, someone will ask that same
"What possible use..." question, except the number of
Thanks.
Yeah, guess I was naive to test on Windows and expect that kind
of process stuff to be portable. I'll be away from Linux for a
week or so, so this will take me a while.
Further bulletins as events warrant.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
Nodir Gulyamov wrote:
> [...]I should show you real code
[...]
> Please find below real code. Sorry for amount of sources.
Yeah, it's too much for me. Can you construct a minimal
example that doesn't do what you think it should?
--
--Bryan
--
http://mail.python.org/mailman
7;s3 = s1+s', but I
> don't know how to construct s1 dynamically (i.e., given N, construct
> "N" followed by N-1 "0", where "N" and "0" are single byte values with
> N<16). How do I do this?
chr(N) + '\x00' * (N - 1)
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
ather-than-on-experimentation assertion, or redefine "not
> dopey" to mean "surely nobody would search for ^x when match x would do,
> so it would be dopey to optimise re for that" :-)
No question, there's some dopiness to searching for the
beginning of the string a
range(9, -1, -2)]
> [9, 7, 5, 3, 1]
> >>>
>
> Looks good to me. indices has returned a usable (start, stop, step).
> Maybe the docs need expanding.
But not a usable [start: stop: step], which is what 'slice' is
all about.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
port.
> BTW, a simpler example of the same phenomenon is:
>
> py> range(10)[slice(None, None, -2)]
> [9, 7, 5, 3, 1]
> py> slice(None, None, -2).indices(10)
> (9, -1, -2)
> py> range(10)[9:-1:-2]
> []
Ah, thanks.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
kely problem is that the stack size is
too large, so you're running out of virtual address space.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
Sorry to sound like an old guy, but wow, how times change.
Incidentally, since your files are jpegs, they're already
compressed, and thus TarFile should be just as good as ZipFile
anyway.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
from foreign
thread.')
And then begin each non-thread-safe function like:
def SomeUpdateFunction(*args):
check_thread()
# ...
[...]
> Even simpler for some purposes is wx.CallAfter(),
Ah, Nice. Same method under the hood, but hides the complexity.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
eback (most recent call last):$
>
> Any idea what's wrong?
Darn. Are you on Windoze/Mac/Unix/, and what version?
If you can spare the time, could you please try:
import errorwindow
import sys
sys.stderr.write("Hello\nWorld.\n")
x = 7 + nosuchvariable
and t
le thread just to manage a download process which is
motly IO and a little bookkeeping is
> silly. Twisted's approach just makes a lot more sense and simplifies
the code too.
I couldn't disagree more about that being easier and simplifying
the code. "Creating a whole thread" is trivial.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
Good start-stop-step values are (9, None, -2), or (9, -11, -2),
or (-1, -11, -2). The later two have the advantage of being
consistend with the documented behavior of returning three
integers.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
in doSomeJob, so no one can ever trigger the even.
>
> Actually I have 2 threads. One of them is MainThread and second one is
> created by Observer in which update method called.
Whatever other thread you have in other code, this code is
whacked. Who do you think calls cl1.increaseCounter(), and how
did they get a reference to cl1?
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
?
>
> Can someone give me a hint ?
In the current Python implementation, more things are atomic
than the language guarantees to be atomic. Programmers should
not depend on that behavior. Again, I don't know anything about
pytz, but we wouldn't bother with locks and semaphores an
:
>
> a, b, c, d = [], [], [], []
Incidentally, to create a list of 37 distinct empty lists, you
can use:
[[] for _ in range(37)]
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
self.c.increaseCounter()
>
> if __name__ == "__main__":
> cl1 = class1()
> m = monitor(cl1)
> mo = MonitorObserver(m)
Obviously that won't work. You only have one thread, and it blocks
in doSomeJob, so no one can ever trigger the even.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
Nodir Gulyamov wrote:
> Hi Bryan,
> Thanks for your reply.
> I tried to test your solution, but it doesn't work, hence
> threading.Semaphore object hasn't method to get value of semaphore.
> I looked to source code of semaphore.py and find out that value is
p
Peter Hansen wrote:
> Bryan Olson wrote:
>
>> Here's a module to show stderr output from console-less Python
>> apps, and stay out of the way otherwise. I plan to make a ASPN
>> recipe of it, but I thought I'd run it by this group first.
>
> For wha
indow
a = 3 + 1 + nonesuchdefined
should cause a window to appear, showing the traceback of a
Python NameError.
--
--Bryan
"""
Import this module into graphical Python apps to provide a
sys.stderr. No
way to make resources show up in Network
> Neighborhood. [...]
Hmmm, you have a point. Looks like he has elements of both local
file systems and networking protocols. To make his special
filesystem transparent to MS-Windows programs is an installable-
filesystem problem, which is what I was looking at.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
Jeff Schwab wrote:
> You don't have to pay Microsoft to develop a Windows-compatible
> filesystem. See http://ubiqx.org/cifs/.
That's a different usage of "filesystem" than what is at issue
here.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
er
strings of data and are used to allow partial error recovery
on decompression
That's not correct. Z_FULL_FLUSH allows recovery after errors,
but Z_SYNC_FLUSH is just to allow pushing all the compressor's
input to the decompressor's output.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
ows IFS
(Installable File System) Developer's Kit costs like $900. Doing
it well would be a large and expensive project. Read their posts
for more discouragement.
> Thanks forward for help.
Not exactly helpful was I? Sorry.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
27;s a good thing to do. The tricky part is getting an
event loop to wait on both the queue and other kinds of events.
Periodic polling works, but kind of sucks.
What's the 'done' argument? A lock maybe?
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
ase()
def doSomeJob(self):
# Busy-waiting sucks.
# while counter != 1:
#pass
self.counter.acquire()
# ... continue...
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
mport threading
class class1:
def __init__(self):
self.counter = threading.semaphore(0)
result = doSomeJob()
def increaseCounter(self):
self.counter.release()
doSomeJob(self):
# Busy-waiting sucks.
# while counter != 1:
#pass
arifications. One more question, can I catch this
exception in my main thread and then do another sys.exit() to kill the whole
process?
Apparently sys.exit() allows the program to clean up resources and exit
gracefully, while os._exit() is rather abrupt.
Bryan
--
http://mail.python.org/mailman/listinfo/python-list
Quick question:
Why does os._exit called from a Python Timer kill the whole process while
sys.exit does not? On Suse.
Bryan
--
http://mail.python.org/mailman/listinfo/python-list
to see wx included in the standard distrubution.
bryan
--
http://mail.python.org/mailman/listinfo/python-list
>Hi Bryan,
>Here's a potential idea. Try converting the variable to a string by
>using the following syntax:
> thePath = str(thePathArg)
Actually it was a stupid thing, what happened was I was looping through the
commandline to build a file path in cases where there
tting
something unexpected obviously.
Any help on what this error is?
Thanks
--
Bryan Rasmussen
--
http://mail.python.org/mailman/listinfo/python-list
i have never
found these interpreters to be anything but very robust and *IT IS SUITABLE* as
trial'n'error pad for real-world programming. the above comment can possible
only be made by someone who doesn't actually use it for real world programming.
bryan
--
http://mail.python.org/mailman/listinfo/python-list
tocompletion feature you talk, and I think this feature is very
> important. Where it is?
>
> Daniel
>
i saw this message too and i've been using it for the last couple days, but i
don't see the class/functions browser you are talking about. where is it???
thanks,
bryan
--
http://mail.python.org/mailman/listinfo/python-list
27;t speak to
that, but i've never experienced an IO hang related to perforce.
bryan
--
http://mail.python.org/mailman/listinfo/python-list
olest things i've
ever seen :)
thanks,
bryan
--
http://mail.python.org/mailman/listinfo/python-list
Bryan wrote:
is there a way to determine the operating system's language? i can't
seem to find a method that returns the value.
thanks,
bryan
found it myself, thanks...
>>> import locale
>>> locale.getdefaultlocale()
('en_US', 'cp1252')
>>>
--
http://mail.python.org/mailman/listinfo/python-list
is there a way to determine the operating system's language? i can't seem to
find a method that returns the value.
thanks,
bryan
--
http://mail.python.org/mailman/listinfo/python-list
i:i+60]
couldn't you change the above for loop to:
print wraptext.fill(seq, 60)
bryan
def main():
seq = []
for line in sys.stdin:
if line[0] in ';>':
show(''.join(seq))
print line,
del seq[:]
else:
http://xahlee.org/PageTwo_dir/more.html
this is the first thing that came to my mind. i'm sure there are more clever
ways to do this.
elements = [['x', 'x', 'x', '1'],
['x', 'x', 'x', '2'],
['x', 'x', 'x', '2'],
['x', 'x', 'x', '2'],
['x', 'x', 'x', '3'],
['x', 'x', 'x', '4'],
['x', 'x', 'x', '5'],
['x', 'x', 'x', '5']]
pos = {}
for i, element in enumerate(elements):
pos.setdefault(element[-1], []).append(i+1)
p = pos.values()
p.sort()
[[1], [2, 3, 4], [5], [6], [7, 8]]
bryan
--
http://mail.python.org/mailman/listinfo/python-list
Duncan Booth wrote:
Bryan wrote:
is to reset the rightmost (less significant) '1' bit of a number (ie
change it to '0').
i tried c &= c - 1 but i'm not getting the least significant or
rightmost bit reset to zero. am i misunderstanding something?
2 & 1 # 2
ange it
to '0').
i tried c &= c - 1 but i'm not getting the least significant or rightmost bit
reset to zero. am i misunderstanding something?
>>> 2 & 1 # 2 = 0x10; reset right most would be 0x10
0
>>> 10 & 9 # 10 = 0x1010; reset right most would be 0x1010
8
bryan
--
http://mail.python.org/mailman/listinfo/python-list
modules index page open and i always wished there was an explicit link to
lists, tuples, dict, set, etc. maybe these explicit links could be at the top
of the __builtins__ page.
bryan
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh wrote:
"Bryan" wrote
the above is not the same. make the a = ... raise an exception and you'll see
the difference.
s = ... #
a = 1/0
s.close()
as you can see, s.close() will never be called. also, in this example, i intentionally didn't put
the extra try/e
Dan Perl wrote:
"Bryan" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
IMO, that is not the reason for the try/finally statement and it is not
redundant. the try/finally statement guarantees the resource is closed
and the try/finally statement only gets execute
nt only gets executed if and only if the opening of the
resource doesn't raise an exception. it has nothing to do with exception handling.
in the previous 2 examples s = ... was placed inside the try/finally, but if an
exception occures and s doesn't get bound to an object, then s.
Eric Pederson wrote:
From: Arthur <[EMAIL PROTECTED]>
Not sure how Xah got himself into all this.
One can easily see that Java programmers are geeks who secretly wanted to make the
football team and are now trying to conform, ignoring their language's critical lack of
Prolog syntax. Python c
can anyone tell me how the talks work? there are between 9 and 12 talks for
each time slot. do all talks start at the same time? or are there just four
talks at a time and the columns show what talks are in a given room? is it easy
to go to the talks you want?
thanks,
bryan
--
http
ny gui toolkits, and instead use that space
for more core funcionality.
thanks,
bryan
--
http://mail.python.org/mailman/listinfo/python-list
Hey just doing some preliminary testing with SimpleHTTPServer, and i noticed
that when i request a resource with a query string parameters that this was not
handled.
is this correct, or is there a method to set query string handling?
--
Bryan Rasmussen
--
http://mail.python.org/mailman
Nick Coghlan wrote:
Bryan wrote:
i'm also curious if it's possible to write this recipe using the new
class style for the Deffered class.it appears you can nolonger
delegate all attributes including special methods to the contained
object by using the __getattr__ or the new __geta
attr__ or
the new __getattribute__ methods. does anyone know how to port this recipe to
the new class style?
thanks,
bryan
--
http://mail.python.org/mailman/listinfo/python-list
, 3, 3)
True
>>> sys.hex_version
Traceback (most recent call last):
File "", line 1, in ?
AttributeError: 'module' object has no attribute 'hex_version'
bryan
--
http://mail.python.org/mailman/listinfo/python-list
701 - 754 of 754 matches
Mail list logo