Click here to Skip to main content
13,800,574 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I am trying to read many log files stored across multiple servers as part of log monitoring. usually the process takes 30-60 seconds to finish a monitoring cycle time, but if there is any issue with particular server the server log file reading takes longer than expected.

I want my program to send an alert if a particular server log file is unreadable for certain time frame and process the next one.

What approach should I take? so that the following lines cab be skipped if it takes more than the specified intervall?

What I have tried:

try:
with open(logServerFilename, 'r') as content_file:
newcontent= content_file.read()
Posted 6-Dec-18 19:48pm
Updated 7-Dec-18 4:16am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You need a timer that will interrupt your code, or a separate thread that can signal you when a number of seconds have elapsed. See threading — Thread-based parallelism — Python 3.7.1 documentation[^] and threading — Timer[^].
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.181215.1 | Last Updated 7 Dec 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100