These methods are called as revdebug.clear() for example.
Flush the record buffers of all threads to network if live recording, otherwise does nothing.
exception(type, value, traceback)
Signal an unhandled exception to be recorded in a live recording and sent as a crash event. If three parameters are specified they must be the exception type, value and traceback as returned by sys.exc_info().
If a single argument is passed then it must be a valid BaseException object as would received by except BaseException as exc.
If no arguments are present then the function assumes it is being called from an except handler and gets the exception information the Python interpreter.
Set the current recording mode to Continuous / Live, OnEvent / Crash or Off. The recording mode can only be set as high as the server allows, so if the server does not allow continuous recording then that will not happen and only unhandled exceptions will be sent to the server. The available recording modes are revdebug.Off, revdebug.Continuous, revdebug.Live, revdebug.OnEvent and revdebug.Crash. Continuous and Live are aliases as are OnEvent and Crash.
Isolate the currently execution async task context (if any) from other recordings. If the optional positional argument clear is True (default) then if this recording block already exists it will be cleared, which mimics the behavior of a newly created isolation block which starts out empty.
Send a snapshot of the current thread execution recording, name is optional and will be an automatically generated increasing sequence name if not provided.
Same as snapshot() except sends all threads.
Clear the record buffer for the current thread. This can be useful if you want to get rid of any references that might be recorded but you don't want RevDeBug to hold for other reasons. If optional positional argument flush is True (default) then if currently live recording then the buffer will be flushed before clearing and no data is lost, otherwise there will be a hole in the live recording where this function cleared the record buffer.
Same as clear() except clears all thread buffers.
record(obj or path)
Turn on recording for a code object, function, class, module, filename or entire path. This may be useful if you want to record a certain system library or site-package that is normally not recorded by default rules. Don't try to record really low level system libraries like gc or weakref, bad things will happen. If you turn on recording for a file or a path then that will be remembered so that even if the file or path is not loaded yet, when it gets loaded it will be set accordingly. Turning on recording for a path automatically turns on recording for anything below that path as well. All currently loaded code objects are checked at time of this call and if they match the path they are turned on for recording. This method can also be used as a decorator for functions or classes in the form of @revdebug.record.
norecord(obj or path)
Same as record except turns off recording.
setrecord(obj or path, record)
Same as record and norecord except that you pass if you wish to turn on or off recording as the bool record, this function can not be used as a decorator.
recrepr(type, func)
This allows you to attach a record stringification function to ANY type, whether native Python, external library, extension C type or even internal Python. This is to allow recording of types RevDeBug does not know anything about. When the object representation is needed the object .func() method will be called with self as the object and should return a string. Exceptions in this function are suppressed. Also, when writing this simple function for stringifying an object please do not to start a new thread, process, or execute another program from within it. Also please avoid interactions with locks, semaphores and or thread-safe queues or other objects. This is all because this function is called from a critical section with thread switching disabled to avoid buffer corruption while serializing, so anything that waits for something from another thread will block indefinitely.
Copy link