Threads and time.strptime()
John Machin
sjmachin at lexicon.net
Mon Jul 3 23:27:57 EDT 2006
On 3/07/2006 6:57 PM, Maximilian Michel wrote:
> Hi all,
>
> I have an interesting problem:
> I have written code, that reads a logfile and parses it for date string
> (Thu Jun 29 14:01:23 2006).
> Standalone everthing works fine, all is recognized.
>
> But if I let the same code run in a thread, with the same file as input
> I get the following error:
> ...
> File "sensor.py", line 158, in gotData
> t = time.strptime(s)
> File "/usr/lib/python2.4/_strptime.py", line 293, in strptime
> raise ValueError("time data did not match format: data=%s fmt=%s"
> %
> ValueError: time data did not match format: data=Thu Jun 29 14:01:23
> 2006 fmt=%a %b %d %H:%M:%S %Y
Possibilities:
(1) The thread implementation has acquired extra characters (whitespace
or \x00).
(2) The thread implementation has changed to a locale that doesn't have
"Thu" & "Jun" as day/month name abbreviations.
Try inserting
print "strptime(%r); locale: %r" % (s, locale.getlocale())
before your call to strptime()
HTH,
John
More information about the Python-list
mailing list