summaryrefslogtreecommitdiff
path: root/alot/commands/envelope.py
diff options
context:
space:
mode:
authorTom Prince <tom.prince@ualberta.net>2012-01-28 14:43:04 -0500
committerPatrick Totzke <patricktotzke@gmail.com>2012-01-28 21:22:39 +0000
commit5d0b77b26460e914a5e9990eab50b3638c369d6e (patch)
tree3280e1a1094c8390180d2e282b5cded2b7762c75 /alot/commands/envelope.py
parent0de42edbed08c04fae0be3c591198d71ff1a84e3 (diff)
Remove direct use of threading.
twisted includes tools for handling threaded code nicely. Use it.
Diffstat (limited to 'alot/commands/envelope.py')
-rw-r--r--alot/commands/envelope.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index 2d209d19..af26b1ed 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -5,7 +5,7 @@ import logging
import email
import tempfile
from twisted.internet.defer import inlineCallbacks
-import threading
+from twisted.internet import threads
import datetime
from alot.account import SendingMailFailed
@@ -136,19 +136,17 @@ class SendCommand(Command):
ui.notify('failed to send: %s' % returnvalue,
priority='error')
- write_fd = ui.mainloop.watch_pipe(afterwards)
-
def thread_code():
mail = envelope.construct_mail()
try:
account.send_mail(mail)
except SendingMailFailed as e:
- os.write(write_fd, unicode(e))
+ return unicode(e)
else:
- os.write(write_fd, 'success')
+ return 'success'
- thread = threading.Thread(target=thread_code)
- thread.start()
+ d = threads.deferToThread(thread_code)
+ d.addCallback(afterwards)
@registerCommand(MODE, 'edit')