| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a2b23b0 commit d627ca4
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,6 +36,7 @@ def __init__(self, | |||
| 36 | 36 | session_root, | |
| 37 | 37 | watch_fn=None, | |
| 38 | 38 | thread_name_filter=None, | |
| 39 | + pass_through_operrors=None, | ||
| 39 | 40 | log_usage=True): | |
| 40 | 41 | """Constructor of DumpingDebugWrapperSession. | |
| 41 | 42 | ||
@@ -56,6 +57,8 @@ def __init__(self, | |||
| 56 | 57 | thread_name_filter: Regular-expression white list for threads on which the | |
| 57 | 58 | wrapper session will be active. See doc of `BaseDebugWrapperSession` for | |
| 58 | 59 | more details. | |
| 60 | + pass_through_operrors: If true, all captured OpErrors will be | ||
| 61 | + propagated. By default this captures all OpErrors. | ||
| 59 | 62 | log_usage: (`bool`) whether the usage of this class is to be logged. | |
| 60 | 63 | ||
| 61 | 64 | Raises: | |
@@ -67,7 +70,8 @@ def __init__(self, | |||
| 67 | 70 | pass # No logging for open-source. | |
| 68 | 71 | ||
| 69 | 72 | framework.NonInteractiveDebugWrapperSession.__init__( | |
| 70 | - self, sess, watch_fn=watch_fn, thread_name_filter=thread_name_filter) | ||
| 73 | + self, sess, watch_fn=watch_fn, thread_name_filter=thread_name_filter, | ||
| 74 | + pass_through_operrors=pass_through_operrors) | ||
| 71 | 75 | ||
| 72 | 76 | if gfile.Exists(session_root): | |
| 73 | 77 | if not gfile.IsDirectory(session_root): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -337,7 +337,8 @@ class BaseDebugWrapperSession(session.SessionInterface): | |||
| 337 | 337 | # TODO(cais): Add on_cont_start and on_cont_end callbacks once the stepper is | |
| 338 | 338 | # is available. | |
| 339 | 339 | ||
| 340 | - def __init__(self, sess, thread_name_filter=None): | ||
| 340 | + def __init__(self, sess, thread_name_filter=None, | ||
| 341 | + pass_through_operrors=False): | ||
| 341 | 342 | """Constructor of `BaseDebugWrapperSession`. | |
| 342 | 343 | ||
| 343 | 344 | Args: | |
@@ -349,6 +350,8 @@ def __init__(self, sess, thread_name_filter=None): | |||
| 349 | 350 | by applying the `match` method of the compiled pattern. The default | |
| 350 | 351 | `None` means that the wrapper session will be active on all threads. | |
| 351 | 352 | E.g., r"MainThread$", r"QueueRunnerThread.*". | |
| 353 | + pass_through_operrors: If True, all captured OpErrors will be | ||
| 354 | + propagated. By default this captures all OpErrors. | ||
| 352 | 355 | ||
| 353 | 356 | Raises: | |
| 354 | 357 | ValueError: On invalid `OnSessionInitAction` value. | |
@@ -361,6 +364,8 @@ def __init__(self, sess, thread_name_filter=None): | |||
| 361 | 364 | self._sess = sess | |
| 362 | 365 | self._thread_name_filter_pattern = (re.compile(thread_name_filter) | |
| 363 | 366 | if thread_name_filter else None) | |
| 367 | + # TODO(cais/kstevens): Unittest this pass through feature. | ||
| 368 | + self._pass_through_operrors = pass_through_operrors | ||
| 364 | 369 | ||
| 365 | 370 | # Keeps track of number of run calls that have been performed on this | |
| 366 | 371 | # debug-wrapper session. The count can be used for purposes such as | |
@@ -480,6 +485,8 @@ def run(self, | |||
| 480 | 485 | options=decorated_run_options, | |
| 481 | 486 | run_metadata=run_metadata) | |
| 482 | 487 | except errors.OpError as op_error: | |
| 488 | + if self._pass_through_operrors: | ||
| 489 | + raise op_error | ||
| 483 | 490 | tf_error = op_error | |
| 484 | 491 | retvals = op_error | |
| 485 | 492 | ||
@@ -783,7 +790,8 @@ def __repr__(self): | |||
| 783 | 790 | class NonInteractiveDebugWrapperSession(BaseDebugWrapperSession): | |
| 784 | 791 | """Base class for non-interactive (i.e., non-CLI) debug wrapper sessions.""" | |
| 785 | 792 | ||
| 786 | - def __init__(self, sess, watch_fn=None, thread_name_filter=None): | ||
| 793 | + def __init__(self, sess, watch_fn=None, thread_name_filter=None, | ||
| 794 | + pass_through_operrors=False): | ||
| 787 | 795 | """Constructor of DumpingDebugWrapperSession. | |
| 788 | 796 | ||
| 789 | 797 | Args: | |
@@ -802,12 +810,15 @@ def __init__(self, sess, watch_fn=None, thread_name_filter=None): | |||
| 802 | 810 | thread_name_filter: Regular-expression white list for threads on which the | |
| 803 | 811 | wrapper session will be active. See doc of `BaseDebugWrapperSession` for | |
| 804 | 812 | more details. | |
| 813 | + pass_through_operrors: If true, all captured OpErrors will be | ||
| 814 | + propagated. By default this captures all OpErrors. | ||
| 805 | 815 | Raises: | |
| 806 | 816 | TypeError: If a non-None `watch_fn` is specified and it is not callable. | |
| 807 | 817 | """ | |
| 808 | 818 | ||
| 809 | 819 | BaseDebugWrapperSession.__init__( | |
| 810 | - self, sess, thread_name_filter=thread_name_filter) | ||
| 820 | + self, sess, thread_name_filter=thread_name_filter, | ||
| 821 | + pass_through_operrors=pass_through_operrors) | ||
| 811 | 822 | ||
| 812 | 823 | self._watch_fn = None | |
| 813 | 824 | if watch_fn is not None: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments