exception should not stop program.

Prabu T.S. prabu.ts at gmail.com
Sat Oct 7 12:41:32 EDT 2017


On Saturday, October 7, 2017 at 12:38:11 PM UTC-4, Prabu T.S. wrote:
> I would like to continue to second function invocation "checkServiceStatus('AdobeARMservice')" even if the first 
>    checkServiceStatus('Tomcat9')  has any exception.Please advice.Second function invocation not getting executed if any exception occurs in first.Please advice.
> 
> 
> import psutil
> 
> def checkServiceStatus(server):
>     status = None
>     try:
>         service = psutil.win_service_get(server)
>         status = service.as_dict()
>         print("%s (%s)" % (status['name'], status['display_name']))
>         print("status: %s, start: %s, username: %s, pid: %s" % (
>         status['status'], status['start_type'], status['username'], status['pid']))
>         print("binpath: %s" % status['binpath'])
>         print(" ")
>     except Exception:
>         pass
>     return status
> 
> checkServiceStatus('Tomcat9')
> checkServiceStatus('AdobeARMservice')

ignore this for now.



More information about the Python-list mailing list