当前位置:网站首页>[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘

[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘

2022-07-07 12:34:00 Sickle leek

AttributeError: module 'signal' has no attribute 'SIGALRM'

Problem description :

When using spellpy When parsing log files , The following error occurred :
The code executed is :

for log_name in ['openstack_abnormal.log', 'openstack_normal2.log', 'openstack_normal1.log']:
	parser.parse(log_name)

The error message is :

Traceback (most recent call last):
  File "preprocess.py", line 62, in <module>
    parser.parse(log_name)
  File "D:\Anaconda\lib\site-packages\spellpy\spell.py", line 188, in parse
    self.load_data()
  File "D:\Anaconda\lib\site-packages\spellpy\spell.py", line 300, in load_data
    self.df_log = self.log_to_dataframe(os.path.join(self.path, self.logname), regex, headers, self.logformat)
  File "D:\Anaconda\lib\site-packages\spellpy\spell.py", line 316, in log_to_dataframe
    signal.signal(signal.SIGALRM, self._log_to_dataframe_handler)
AttributeError: module 'signal' has no attribute 'SIGALRM'

Problem analysis

spell Called signal modular , This module can be used in linux Under normal use , But in windows But there are some restrictions :
“On Windows, signal() can only be called with SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, or SIGTERM. A ValueError will be raised in any other case.”

stay Windows Only these signal types are allowed to be used in the environment :

  • SIGABRT
  • SIGFPE
  • SIGILL
  • SIGINT
  • SIGSEGV
  • SIGTERM
原网站

版权声明
本文为[Sickle leek]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071027577557.html