[issue29090] python34.dll crash

2016-12-27 Thread Mike Hobbs

New submission from Mike Hobbs:

Only info (Windows event viewer): Faulting application python_cc.exe, version 
0.0.0.0, faulting module python34.dll, version 3.4.3150.1013, fault address 
0x001059b7
Note: python_cc.exe is renamed python.exe to identify it in task manager.
OS is Windows XP SP3

The following script crashes the python executable every few hours (not 
regular, seemingly random).
The exact same script also crashes python 2.7.13. Each version has the latest 
pyserial module installed for the appropriate python version.
When python 2.7 crashes, the reported error is always in _ctypes.dll which is 
used extensively in the serialwin32.py for reading the serial port, but python 
3.4 fails in the main DLL.

This same script has been running without a problem for several years on the 
same hardware (Quad core Shuttle with CurrentCost 128 electricity monitor on 
COM3, using PL2303 serial/USB chipset (probably clone)). The crashes have only 
occured since harddisc replacement involving new XP installation and 
reinstallation of application software.

Occasionally, the crash results in a blue screen but usually its just the task 
crash notification (which I automatically dismiss using AutoIt3 watchdog 
script).  Everything else on the machine id running normally so the serial port 
handling is the prime suspect.


import serial, sys, time, traceback, os
import xml.etree.ElementTree as ET

correction = 1.074  # 247V when CC128 is designed for 230V
path = "E:\\Apache\\htdocs\\energy\\elec_data\\"
log  = "E:\\Apache\\htdocs\\energy\\log.txt"
ser  = None
amps = [0,0,0,0]

def localtime():
y,m,d,h,mn,s,wd,b,c = time.localtime()
return '%4d%02d%02d %02d%02d%02d' % (y,m,d,h,mn,s)

def dbg(msg):
msg = msg.strip()
print(msg)
if len(msg) <= 2: return
global log
# avoid huge files
if os.path.getsize(log) > 200:
y,m,d,h,mn,s,wd,b,c = time.localtime()
old = 'log_%4d%02d%02d_%02d%02d%02d.txt' % (y,m,d,h,mn,s)
os.rename(log, old)
f = open(log, 'a')
t = localtime()
f.write('%s %s\n' % (t, msg))
f.close()

try:
ser = serial.Serial(port="COM3", baudrate=57600, bytesize=serial.EIGHTBITS, 
parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=3)
dbg("Connected to CurrentCost meter")

except serial.SerialException:
dbg("Failed to connect to CurrentCost meter")
sys.exit(1)

err_count = 0
while True:
try:
line = ser.readline().strip() # should be something every 6 seconds
if line:
watts = ''
try:
msg = ET.fromstring(line)
watts = msg.findtext('ch1/watts')
watts = float(watts)
err_count = 0
except:
watts = ''
err_count += 1
finally:
try:
del exc_info
except:
pass

if watts:
# _ _  _  _
#  _   or   __  regarded as bogus
amps[0] = amps[1]; amps[1] = amps[2]; amps[2] = amps[3]
amps[3] = float(watts)*.00405 # 247 volts
bogus = False
if amps[1]>0 and amps[1] < amps[0]/2:
if amps[1] < amps[2]/2: bogus = True
if amps[1] < amps[3]/2 and amps[2] < amps[3]/2: bogus = True
#dbg('%s  %s  %s  %s  %s' % 
(amps[0],amps[1],amps[2],amps[3],bogus))
if not bogus and amps[2]>0 and amps[3]>0:
y,m,d,h,mn,s,a,b,c = time.localtime()
try:
line = '%f,%f' % (float(h)+float(mn)/60+float(s)/3600, 
amps[1])
f = open('%s\\%4d%02d%02d.csv' % (path,y,m,d), 'a')
f.write('%s\n' % line)
f.close()
except:
exc_info = sys.exc_info()
dbg('CC EXCEPTION %s ' % 
traceback.format_exception(*exc_info))
finally:
try:
del exc_info  # force garbage collection
except:
pass
else:
if err_count > 100:
dbg("100 consecutive errors detected")
break

except serial.SerialException:
exc_info = sys.exc_info()
dbg('CC EXCEPTION %s ' % traceback.format_exception(*exc_info))
ser.close()
sys.exit(1)
except KeyboardInterrupt:
ser.close()
sys.exit(0)
except:
exc_info = sys.exc_info()
dbg('CC EXCEPTION %s ' % traceback.format_exception(*exc_info))
finally:
try:
del exc_info  # force garbage collection
except:
pass

ser.close()
sys.exit(1)

--
components: Windows
mes

[issue14623] Shutdown exception in daemon thread

2012-04-19 Thread Mike Hobbs

New submission from Mike Hobbs mho...@8thbridge.com:

This issue is very similar to the issue original reported in issue1722344, 
except that it occurs in daemon threads. Here's a sample exception:

Exception in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File /usr/local/lib/python2.7/threading.py, line 552, in __bootstrap_inner
  File /usr/local/lib/python2.7/threading.py, line 505, in run
  File /opt/8b/libr8/eb/util/graphite.py, line 86, in run
  File /usr/local/lib/python2.7/Queue.py, line 168, in get
  File /usr/local/lib/python2.7/threading.py, line 237, in wait
type 'exceptions.TypeError': 'NoneType' object is not callable

Investigating line 237 in threading.py shows that RuntimeError must have been 
set to None. The issue appears to be that Py_Finalize wipes all globals while 
there are still daemon threads running. Would it be correct to terminate daemon 
threads prior to wiping the globals, since the threads won't be able to 
accomplish much anyway?

--
components: Interpreter Core
messages: 158746
nosy: mhobbs
priority: normal
severity: normal
status: open
title: Shutdown exception in daemon thread
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14623
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8844] Condition.wait() doesn't raise KeyboardInterrupt

2010-05-28 Thread Mike Hobbs

New submission from Mike Hobbs mho...@alvenda.com:

Condition.wait() without a timeout will never raise a KeyboardInterrupt:

cond = threading.Condition()
cond.acquire()
cond.wait()

*** Pressing Ctrl-C now does nothing ***



If you pass a timeout to Condition.wait(), however, it does behave as expected:

cond.wait()

^CTraceback (most recent call last):
  File /usr/lib/python3.1/threading.py, line 242, in wait
_sleep(delay)
KeyboardInterrupt



This may affect other problems reported with multiprocessing pools. Most 
notably:
http://bugs.python.org/issue8296
http://stackoverflow.com/questions/1408356

--
components: Library (Lib)
messages: 106678
nosy: hobb0001
priority: normal
severity: normal
status: open
title: Condition.wait() doesn't raise KeyboardInterrupt
type: behavior
versions: Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8844
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com