pledgecamp / pledgecamp-mail-tester

Capture Mailgun API calls and render emails for testing.
0 stars 0 forks source link

#2 Add db connection cleanup after query #6

Closed kelvin-wong closed 3 years ago

kelvin-wong commented 3 years ago

close #2

gh-2

import asyncio

import requests

async def post_mail() -> None:
    post_mail_loop = asyncio.get_event_loop()
    futures = [
        post_mail_loop.run_in_executor(
            None,
            requests.post,
            'http://mail-test.localdev.com:4020/api/messages',
            {
                'from': 'from@example.com',
                'to': 'to@example.com',
                'subject': 'subject',
                'text': 'text',
                'html': 'html',
            },
        )
        for _ in range(2**8)
    ]
    await asyncio.gather(*futures)

loop = asyncio.get_event_loop()
loop.run_until_complete(post_mail())

Attached a python script for reproducing the case

sampullman commented 3 years ago

Thanks! I tested it and it looks like this solves the issue.

The test is good, it would be nice to have some unit tests in Go like that. I'll create an issue, though it's not too urgent.