Package: timeframe-event
timeframePython timeframe tool for time monitoring for each event, error handling, traceback recording...How to installpipinstalltimeframe-eventYou can also copy timeframe.py fromGitHuband drop it in your projectThis project/file only uses standard libraries so installation of additional dependency is not requiredExampleimportrandom,timefromtimeframeimportTimeFrameasyncdeffunc(timeframe:TimeFrame,*args,**kwargs):# Create rt(realtime) functiontimeframe.print_mono()print(args,kwargs)withTimeFrame('test args',name='Text request',rt=func,test_kwargs='test kwargs')astime_frame:withtime_frame.create(name='Prompt')asgroup_prompt:withgroup_prompt.create(name='Prompt request',retries=5,ignore_retries=(TimeoutError,))asevent_frame:function_call=Falseforframeinevent_frame:asyncwithframe:time.sleep(random.uniform(0,0.4))# Stimulate doing network operationifrandom.random()<0.2:raiseValueError# Stimulate a complete random chance of a network error occurifrandom.random()<0.3:raiseTimeoutError# Stimulate a complete internet breakdownifrandom.random()<0.9:function_call=Trueiffunction_call:withgroup_prompt.create(name='Function call `mul`',retries=0):time.sleep(random.uniform(0,0.01))# Stimulate doing network operationwithgroup_prompt.create(name='Function Response',retries=5)asevent_frame:forframeinevent_frame:asyncwithframe:time.sleep(random.uniform(0,0.4))# Stimulate doing network operationifrandom.random()<0.7:raiseValueError# Stimulate a complete random chance of a network error occur>>> print(time_frame.traceback_format())
[596869.233s] Error raised on Attempt 'Attempt #1' from parent 'Prompt request' at TimeFrame 'Text request':
Traceback (most recent call last):

  File "...\timeframe.py", line 260, in test
    raise ValueError  # Stimulate a complete random chance of a network error occur
    ^^^^^^^^^^^^^^^^

ValueError

[596869.397s] Error raised on Attempt 'Attempt #2' from parent 'Prompt request' at TimeFrame 'Text request':
Traceback (most recent call last):

  File "...\timeframe.py", line 260, in test
    raise ValueError  # Stimulate a complete random chance of a network error occur
    ^^^^^^^^^^^^^^^^

ValueError

[596870.032s] Error raised on Attempt 'Attempt #1' from parent 'Function Response' at TimeFrame 'Text request':
Traceback (most recent call last):

  File "...\timeframe.py", line 271, in test
    raise ValueError  # Stimulate a complete random chance of a network error occur
    ^^^^^^^^^^^^^^^^

ValueError

[596870.171s] Error raised on Attempt 'Attempt #2' from parent 'Function Response' at TimeFrame 'Text request':
Traceback (most recent call last):

  File "...\timeframe.py", line 271, in test
    raise ValueError  # Stimulate a complete random chance of a network error occur
    ^^^^^^^^^^^^^^^^

ValueError>>> print(time_frame.frame_format_dc(limit=1024)) #Character limit of discord embed field value
Total: 0001.252s (Total Frames: 11)
✅-Prompt (0001.252s)
> ⚠️-Prompt request (0000.607s)
> - ❌-Attempt #1 (0000.203s)
> - ❌-Attempt #2 (0000.164s)
> - ✅-Attempt #3 (0000.240s)
> ✅-Function call `mul` (0000.005s)
> ⚠️-Function Response (0000.640s)
> - ❌-Attempt #1 (0000.390s)
> - ❌-Attempt #2 (0000.139s)
> - ✅-Attempt #3 (0000.111s)Example:>>> print(time_frame.frame_format_mono()) # Use of export as file or display on console
Total: 0001.252s (Total Frames: 11)
✅-Text request (0001.252s)
  ✅-Prompt (0001.252s)
    ⚠️-Prompt request (0000.607s)
      ❌-Attempt #1 (0000.203s)
      ❌-Attempt #2 (0000.164s)
      ✅-Attempt #3 (0000.240s)
    ✅-Function call `mul` (0000.005s)
    ⚠️-Function Response (0000.640s)
      ❌-Attempt #1 (0000.390s)
      ❌-Attempt #2 (0000.139s)
      ✅-Attempt #3 (0000.111s)print(timeframe.frame_format_custom()) # Default with markdownTotal: 0000.826s (Total Frames: 11)✅-Prompt (0000.826s)⚠️-Prompt request (0000.690s)❌-Attempt #1 (0000.135s)❌-Attempt #2 (0000.020s)❌-Attempt #3 (0000.126s)❌-Attempt #4 (0000.349s)✅-Attempt #5 (0000.060s)✅-Function callmul(0000.004s)✅-Function Response (0000.132s)