Skip to content
Snippets Groups Projects

#390, #396, #407: Drop async, send_doc(), Documents BBC

Merged #390, #396, #407: Drop async, send_doc(), Documents BBC
All threads resolved!
Merged Moul requested to merge 390_396_remove_asynchronous_property into dev
All threads resolved!
  • Upgrade to DuniterPy v1.0.0rc0
  • Remove asynctest and pytest-asyncio no longer required dependencies
  • Handle DuniterPy v1.0 Documents BBC
  • Refactor test_generate_and_send_transaction()
  • Implement generic send_document()
  • Remove async/await keywords from tests/test_*.py
  • Remove async kw from tests/patched
  • wot: Handle 404 error not found exception
  • Remove client.close() now in DuniterPy
  • Remove aiohttp module usage
  • Remove async/await keywords

Close #3 (closed), #260 (closed), #390 (closed), #396 (closed), #407 (closed).

Edited by Moul

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Moul marked this merge request as draft

    marked this merge request as draft

  • Moul changed the description

    changed the description

  • Moul added 36 commits

    added 36 commits

    Compare with previous version

  • Moul added 19 commits

    added 19 commits

    Compare with previous version

  • Moul changed title from Draft: #396 (closed): Remove asynchronous property to Draft: #390, #396 (closed): Remove asynchronous property

    changed title from Draft: #396 (closed): Remove asynchronous property to Draft: #390, #396 (closed): Remove asynchronous property

  • Moul resolved all threads

    resolved all threads

  • Moul changed title from Draft: #390 (closed), #396 (closed): Remove asynchronous property to Draft: #390 (closed), #396 (closed), #407: Remove asynchronous property

    changed title from Draft: #390 (closed), #396 (closed): Remove asynchronous property to Draft: #390 (closed), #396 (closed), #407: Remove asynchronous property

  • Moul changed the description

    changed the description

  • Moul changed title from Draft: #390 (closed), #396 (closed), #407 (closed): Remove asynchronous property to Draft: #390 (closed), #396 (closed), #407 (closed): Drop async, send_doc(), Documents BBC

    changed title from Draft: #390 (closed), #396 (closed), #407 (closed): Remove asynchronous property to Draft: #390 (closed), #396 (closed), #407 (closed): Drop async, send_doc(), Documents BBC

  • Moul added 24 commits

    added 24 commits

    Compare with previous version

  • Moul added 24 commits

    added 24 commits

    Compare with previous version

  • Moul changed the description

    changed the description

  • Moul changed the description

    changed the description

  • Moul changed the description

    changed the description

  • Moul added 4 commits

    added 4 commits

    Compare with previous version

  • Moul assigned to @moul and unassigned @matograine

    assigned to @moul and unassigned @matograine

  • Moul marked this merge request as ready

    marked this merge request as ready

  • Moul added 14 commits

    added 14 commits

    Compare with previous version

  • Moul approved this merge request

    approved this merge request

  • merged

  • matograine
    matograine @matograine started a thread on commit 5dc33eaa
  • 63 65 class ClientInstance:
    64 66 def __init__(self):
    65 67 self.client = Client(EndPoint().BMA_ENDPOINT)
    68
    69
    70 def send_document(bma_path, document):
    71 client = ClientInstance().client
    72 doc_name = document.__class__.__name__
    73 try:
    74 client(bma_path, document.signed_raw())
    75 print(f"{doc_name} successfully sent")
    76 except urllib.error.HTTPError as e:
    77 print(f"Error while publishing {doc_name.lower()}: {e}")
    • When Silkaj encounters an error from the Duniter node, send_document will return 0, which is a success. Should we not return an error code, since something went wrong ?

    • Author Owner

      Thanks for that! We could replace this print() with sys.exit(). I am just afraid it could cause issue in the tx command, since the algorithm is stopped, and therefore the other intermediaries tx are not sent. What do you think? Having exit()s everywhere is also something I want to avoid, in case Silkaj turns into a GUI client. But, you are right for a CLI client, this error should be reported as an exit code in the shell it's running in.

    • Author Owner

      In case we are not sure about tx command and having sys.exit() down in the hierarchy in base functions, we could handle it outside, but it's less elegant, so we can decide on each case whether we want to exit or not the program based on the raised exception:

      def send_document(bma_path, document):
          client = ClientInstance().client
          doc_name = document.__class__.__name__
          client(bma_path, document.signed_raw())
          print(f"{doc_name} successfully sent")
      
      
      # send document cmd
      try:
          send_document(bma_path, document)
      except urllib.error.HTTPError as e:
          sys.exit(f"Error while publishing {document.__class__.__name__.lower()}: {e}")

      But, first, let's check for the tricky tx intermediaries transactions x)

    • Author Owner

      I checked. For cert, membership, and revocation commands, send_document() is at the end of execution of the command/main function. So, this is not a problem for them if there is a sys.exit() call.

      For tx command, in case of:

      • single tx: also at the end of hierarchy, same as the other cmds. Not problematic if it fails.
      • intermediaries tx: a list of intermediaries tx are sent then the final tx. What could happen is that one of the intermediary tx fails to be sent to a Duniter node and exits the program. The planned tx after this one are not sent. This is fine if things get stopped/stuck here since this is summing up sources on to the issuer’s pubkey.

      In summary, I think we a safe adding the sys.exit() call for all cases. Otherwise, I was thinking about something as follow:

      -def send_document(bma_path, document):
      +def send_document(bma_path, document, exit=True)":
          client = ClientInstance().client
          doc_name = document.__class__.__name__
          try:
              client(bma_path, document.signed_raw())
              print(f"{doc_name} successfully sent")
          except urllib.error.HTTPError as e:
              print(f"Error while publishing {doc_name.lower()}: {e}")
      +        if exit:
      +            sys.exit()

      and call send_document(bma_path, intermediary_tx, False) for the intermediaries transactions.


      Thanks for noticing this! It solves an issue I encountered I had with membership tests.

      For you to review: !196 (merged).

    • Please register or sign in to reply
    Please register or sign in to reply
    Loading