How to use _handle_exceptions method in localstack

Best Python code snippet using localstack_python

pydevd_breakpoints.py

Source: pydevd_breakpoints.py Github

copy

Full Screen

1from pydevd_constants import *2import pydevd_tracing3import sys4import pydev_log5import pydevd_import_class6_original_excepthook = None7_handle_exceptions = None8import _pydev_threading as threading9threadingCurrentThread = threading.currentThread10from pydevd_comm import GetGlobalDebugger11class ExceptionBreakpoint:12 def __init__(13 self,14 qname,15 notify_always,16 notify_on_terminate,17 notify_on_first_raise_only,18 ):19 exctype = _get_class(qname)20 self.qname = qname21 if exctype is not None:22 self.name = exctype.__name__23 else:24 self.name = None25 self.notify_on_terminate = notify_on_terminate26 self.notify_always = notify_always27 self.notify_on_first_raise_only = notify_on_first_raise_only28 self.type = exctype29 def __str__(self):30 return self.qname31class LineBreakpoint(object):32 def __init__(self, line, condition, func_name, expression):33 self.line = line34 self.condition = condition35 self.func_name = func_name36 self.expression = expression37def get_exception_full_qname(exctype):38 if not exctype:39 return None40 return str(exctype.__module__) + '.' + exctype.__name__41def get_exception_name(exctype):42 if not exctype:43 return None44 return exctype.__name__45def get_exception_breakpoint(exctype, exceptions):46 exception_full_qname = get_exception_full_qname(exctype)47 exc = None48 if exceptions is not None:49 try:50 return exceptions[exception_full_qname]51 except KeyError:52 for exception_breakpoint in DictIterValues(exceptions):53 if exception_breakpoint.type is not None and issubclass(exctype, exception_breakpoint.type):54 if exc is None or issubclass(exception_breakpoint.type, exc.type):55 exc = exception_breakpoint56 return exc57#=======================================================================================================================58# _excepthook59#=======================================================================================================================60def _excepthook(exctype, value, tb):61 global _handle_exceptions62 if _handle_exceptions:63 exception_breakpoint = get_exception_breakpoint(exctype, _handle_exceptions)64 else:65 exception_breakpoint = None66 #Always call the original excepthook before going on to call the debugger post mortem to show it.67 _original_excepthook(exctype, value, tb)68 if not exception_breakpoint:69 return70 if tb is None: #sometimes it can be None, e.g. with GTK71 return72 frames = []73 while tb:74 frames.append(tb.tb_frame)75 tb = tb.tb_next76 thread = threadingCurrentThread()77 frames_byid = dict([(id(frame),frame) for frame in frames])78 frame = frames[-1]79 thread.additionalInfo.exception = (exctype, value, tb)80 thread.additionalInfo.pydev_force_stop_at_exception = (frame, frames_byid)81 thread.additionalInfo.message = exception_breakpoint.qname82 debugger = GetGlobalDebugger()83 pydevd_tracing.SetTrace(None) #no tracing from here84 pydev_log.debug('Handling post-mortem stop on exception breakpoint %s'% exception_breakpoint.qname)85 debugger.handle_post_mortem_stop(thread.additionalInfo, thread)86#=======================================================================================================================87# _set_pm_excepthook88#=======================================================================================================================89def _set_pm_excepthook(handle_exceptions_dict=None):90 '''91 Should be called to register the excepthook to be used.92 It's only useful for uncaught exceptions. I.e.: exceptions that go up to the excepthook.93 @param handle_exceptions: dict(exception -> ExceptionBreakpoint)94 The exceptions that should be handled.95 '''96 global _handle_exceptions97 global _original_excepthook98 if sys.excepthook != _excepthook:99 #Only keep the original if it's not our own _excepthook (if called many times).100 _original_excepthook = sys.excepthook101 _handle_exceptions = handle_exceptions_dict102 sys.excepthook = _excepthook103def _restore_pm_excepthook():104 global _original_excepthook105 if _original_excepthook:106 sys.excepthook = _original_excepthook107 _original_excepthook = None108def update_exception_hook(dbg):109 if dbg.break_on_uncaught_exceptions:110 _set_pm_excepthook(dbg.break_on_uncaught_exceptions)111 else:112 _restore_pm_excepthook()113def _get_class( kls ):114 if IS_PY24 and "BaseException" == kls:115 kls = "Exception"116 try:117 return eval(kls)118 except:...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

QA Innovation – Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

Best 23 Web Design Trends To Follow In 2023

Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful