Skip to content

Commit

Permalink
Merge 3d91502 into 824cecd
Browse files Browse the repository at this point in the history
  • Loading branch information
aerickson committed Jun 4, 2018
2 parents 824cecd + 3d91502 commit 0ec1237
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
- MAILGUN_API_KEY=testtesttest
- secure: QWNGqrTcNUIdtpBKz1KMsx54SZ5OkQ1eK8SR4iJag4I3UXhT7MIwtbBrWyIEQvoC2in23gp5lPPiG842lPgKebOz+8GyJHYaE7SKPjPdpRfxPJSoDrJagArKNcsZrcZJkAr9jIpqV6Ap7p0TzzOWXsqYDbmLWxgrJOLHTLHi9QZc71vjP4wRhRBtz24xcUgSsRRUrM56FrxSy27zoem4AeJwRRVB52d1HwDbcHtbJ/3taVHFd4WLbdUIbwyOvXX3RGqVv2TxX9YoH+1S18mSoKy+OWulOQyrHc8pjPkz+cNyCYXE2Pu3m97e5c+NzFLsnfqYyKwROM49qGOvXbY0tziVYUAvgoJ1P+fsShKH5WKhv9J917R5QLf12iWKPI3/apBhXb5yGoFOerSxMUgJz4hSuKGTbg7nJ2hWJZVop7+c2LiSbtahghhmjJwlVzNSzTb6X6UayEgVlaqSF7wyq5pJmMXZ7fDxoooTyu4iDjRwYzxH1OrUWYz2Q9pHK7YAf9dHOgnrqaI6f+HQ9qt9auG9pGQ7Ep7tQVcikvWLZEgyqYLClagazqwoJImPrLrip3JVnb4lTudiwn2jKHYVgSjfEJn28aBf9ArtBpIvtnl5Rpe7fHrfeape5zUZlxC0lZ2sYWkoef/KooYWKk1iXOPA59RmswE6G8OZ+KmrV9s=
install:
- pip install -U setuptools
- pip install -U pip
- pip install -r requirements.txt
- pip install -e .
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Flask-MailGun Flask extension to use the [MailGun](https://mailgun.com) email pa
Flask-MailGun allows you to configure your connection into the MailGun api so that you can
- Send emails
- Set up routes
- Handel incoming emails
- Handle incoming emails
- `flask-mailgun3 >= 0.1.4` should work with `flask_security` as a drop in replacement for `flask_mail`

## Usage
Expand Down Expand Up @@ -52,7 +52,7 @@ mailgun.send(message)

## Long Requests

A mechanisom has been put in place to simplify handeling long requests. Basically if your callback function blocks the processing of an email for toolong it will cause the post from the mailgun services to timeout. At the moment this is done by setting the `mailgun.callback_handeler` to `mailgun.async` but you would have to do this before registering the callbacks (you could reregister on init as well).
A mechanisom has been put in place to simplify handling long requests. Basically if your callback function blocks the processing of an email for toolong it will cause the post from the mailgun services to timeout. At the moment this is done by setting the `mailgun.callback_handeler` to `mailgun.async` but you would have to do this before registering the callbacks (you could reregister on init as well).
```python
# at config
app.config['MAILGUN_BG_PROCESSES'] = flask_mailgun.processing.async_pool(NO_PROCS)
Expand All @@ -64,6 +64,6 @@ mailgun.callback_handeler = mailgun.async
mailgun._on_attachment = [mailgun.async(func) for func in mailgun._on_attachment]
```

Async will save the attachment to disk and offload your callback to a process pool, handeling all the file opperations and file cleanup for you.
Async will save the attachment to disk and offload your callback to a process pool, handling all the file opperations and file cleanup for you.

This however is probably not an ideal system (threadding dosnt go to well with flask and the process pool implimentation is not simple), and for something more robust we need to move to a celary based system. Setting up celary server and taksks however are beyond the scope of this extension, (we will provide an example though). In addition it may be beniffichial to move to a notify fetch pattern instead of mailgun posting the email to us, however the implimentation details will remain internal to `flask_mailgun` and the api for `process_attachment` shouldn't change.

0 comments on commit 0ec1237

Please sign in to comment.