Skip to content

Need a way to subscribe to DriverWarning as events with a callback #2088

Open
@vnktshr21

Description

@vnktshr21

With warnings.warn, if users have to asynchronously process driver warnings, then they need to override the warnings.showwarning function with a custom handler which would process driver warnings differently. This implies a global override, more things for users to maintain and a possibility of not handling certain other warnings in the application correctly. Would be good to have a warning event mechanism built into driver session which the users can subscribe to, by passing a callback function. This event mechanism can co-exist with the current warnings.warn. This way, users can adopt whatever approach makes sense for the application.

ie:

  • if they want to raise exceptions for warnings, then they can simply do
    warnings.simplefilter("error", DriverWarning)
  • if they want to asynchronously handle warnings without stopping the execution flow, then they can do
    session.warning_event.subscribe(driverwarninghandler(DriverWarning)) and define
def driverwarninghandler(DriverWarning):
    <log to file, set a flag, push to a queue, raise few warnings and ignore others, etc>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions