View Single Post
Old 2011-06-12, 21:32   #6
D. B. Staple
 
D. B. Staple's Avatar
 
Nov 2007
Halifax, Nova Scotia

23×7 Posts
Default

P.S.
I think I solved the mystery -- the result of the readline is a bunch of null characters. These pass through both the if statement and the whitespace removal, and cause int() to throw a ValueException.

I used this test code:
Code:
def read_spq(fact_p):
  for j in range(SV_THREADS):
    ql, qp, qh = fact_p['q_dq'][j]
    try:
      with open('.last_spq' + str(100 * PNUM + j), 'r') as in_f:
        raw_line = in_f.readline()
        tmp = remove_ws(chomp(raw_line))
        if tmp:
          try:
            t = int(chomp(tmp))
          except ValueError:
            print('raw_line:   ', raw_line)
            print('tmp:        ', tmp)
            print('chomp(tmp): ', chomp(tmp))
            raise
          else:
            if t > qp:
              fact_p['q_dq'][j] = (ql, t, qh)
    except IOError:
      pass
Which produced this output immediately prior to the crash:
Code:
raw_line:    ^@^@^@^@^@^@^@^@
tmp:         ^@^@^@^@^@^@^@^@
chomp(tmp):  ^@^@^@^@^@^@^@^@
siever terminated
D. B. Staple is offline   Reply With Quote