Archives

You are currently viewing archive for July 2009
Category: Web dev
Posted by: hajime osako
Troubleshooting Tools for Java(tm) - AdaptJ Systems LLC

- From the Process menu select Thread Dump. Enter the target Process ID or use the "..." button to select one.
- Use at least one or a combination of the following options:

* Thread dump - returns a thread dump of the target process.
* Use Ctrl-Break - Sends QUIT signal to the process. Do not use this option if your process was started with the -Xrs VM option (a Windows service for example) because the process will exit.
* System properties - returns System.getProperties() for the target process.
* Memory usage - returns Runtime.freeMemory(), Runtime.totalMemory(), and Runtime.maxMemory().
* Process command line - returns the command line used to start the target process.
* Force GC - calls System.gc() inside the target process.
* Create console - creates a console for a process if it does not have one.
* Keep remote thread running - creates a remote thread in the target process which waits for an event to make a thread dump. It helps when the regular thread dump procedure cannot be executed because of the system global locks.

The result of the selected operations will appear inside the StackTrace editor window.
Category: Web dev
Posted by: hajime osako
Category: Web dev
Posted by: hajime osako
8. Errors and Exceptions — Python v2.6.2 documentation


import sys

try:
f = open('myfile.txt')
s = f.readline()
i = int(s.strip())
except IOError as (errno, strerror):
print "I/O error({0}): {1}".format(errno, strerror)
except ValueError:
print "Could not convert data to an integer."
except:
print "Unexpected error:", sys.exc_info()[0]
raise