Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tg post NetError and update docker compose deploy #28

Merged
merged 1 commit into from
Dec 25, 2024

Conversation

Tohrusky
Copy link
Member

@Tohrusky Tohrusky commented Dec 25, 2024

Summary by Sourcery

Update post info generation timing and retry attempts for Telegram posts. Update qBittorrent image to linuxserver/qbittorrent:latest and expose additional ports.

Bug Fixes:

  • Fixed a NetworkError issue in Telegram posts by increasing the retry attempts from 5 to 10 and adding timeouts for network requests.

Enhancements:

  • Generate post information files before sending Telegram messages.

Deployment:

  • Updated the Docker Compose deployment configuration to use the linuxserver/qbittorrent:latest image and expose ports 48008 for both TCP and UDP.

Copy link

sourcery-ai bot commented Dec 25, 2024

Reviewer's Guide by Sourcery

This pull request fixes a network error when posting to Telegram and updates the Docker Compose deployment configuration.

Sequence diagram for updated Telegram posting process

sequenceDiagram
    participant P as Pipeline
    participant T as TelegramSender
    participant TB as TelegramBot

    P->>T: send_text(message)
    activate T
    Note over T: Retry up to 10 times
    Note over T: (increased from 5)
    T->>TB: send_message()
    Note over TB: Increased timeouts:
    Note over TB: read: 60s
    Note over TB: write: 60s
    Note over TB: connect: 60s
    Note over TB: pool: 600s
    alt Network Error
        TB-->>T: Network Error
        T->>T: Retry with random delay (3-15s)
    else Success
        TB-->>T: Success
    end
    T-->>P: Complete
    deactivate T
Loading

File-Level Changes

Change Details Files
Fix Telegram network error by increasing the retry attempts and setting timeouts for network requests.
  • Increased retry attempts from 5 to 10 for sending Telegram messages.
  • Set timeouts for network requests to handle potential network issues when sending messages to Telegram channels.
  • Added read_timeout, write_timeout, connect_timeout, and pool_timeout parameters to the send_message function to prevent indefinite blocking during network operations.
animepipeline/post/tg.py
Generate post info files before sending the Telegram message.
  • Moved the logic for generating post information files (HTML, Markdown, BBCode) to before the Telegram message sending.
  • This ensures that the files are generated even if the Telegram message fails to send.
animepipeline/loop.py
Update Docker Compose configurations.
  • Updated the qBittorrent image to linuxserver/qbittorrent:latest for better compatibility and features.
  • Removed unused network configurations.
  • Exposed additional ports for qBittorrent to improve accessibility.
  • Commented out the alternative qBittorrent Enhanced Edition configuration in docker-compose-animepipeline.yml to simplify the setup.
deploy/docker-compose-animepipeline.yml
deploy/docker-compose-dev.yml
Removed unnecessary network definitions.
  • Removed the networks block and associated configurations from both docker-compose-animepipeline.yml and docker-compose-dev.yml files. This simplifies the Docker Compose setup and removes unnecessary network configurations.
deploy/docker-compose-animepipeline.yml
deploy/docker-compose-dev.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Tohrusky - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider removing the commented-out qb-ee service configuration instead of leaving it in the docker-compose file. If it's needed for reference, it should be documented elsewhere.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +31 to +34
read_timeout=60,
write_timeout=60,
connect_timeout=60,
pool_timeout=600,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): The timeout values seem unnecessarily high for a Telegram message operation

Consider reducing these timeout values. 600 seconds for pool_timeout and 60 seconds for other timeouts might be excessive for sending a message.

Suggested change
read_timeout=60,
write_timeout=60,
connect_timeout=60,
pool_timeout=600,
read_timeout=10,
write_timeout=10,
connect_timeout=10,
pool_timeout=30,

@Tohrusky Tohrusky merged commit 5a4077a into TensoRaws:main Dec 25, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant