20 August 2015

gevent not so parallel

2 issue here.

1) gevent.pool is not so perfect. It would not start new thread untill all running thread exit.
Perfect implementation should start a thread immediately when there is a vacant in the pool.

2) the thread seem not execute parallel. In below example, function do_work_function clearly not running in parallel.

Really feel been bluffing all this while..... thanx 0xpcode :)

from gevent.pool import Pool
import time
import logging

rows = range(10)
pool = Pool(CONCURRENCY)

def do_work_function(param1):
print "start" , str(param1 )
    print "--finish" , str(param1 )
for row in rows:
  pool.spawn(do_work_function,row) # blocks here when pool size == CONCURRENCY
  print "spawn thread %s" % str(row)

print "start join"
pool.join(timeout=1) #blocks here until the last 10 are complete
print "end join" 

13 August 2015

python package

install location (ubuntu 14.04)

email test

HELO local.domain.name

MAIL FROM: mail@domain.ext

RCPT TO: mail@otherdomain.ext

Subject:-type subject here-

ref: http://www.yuki-onna.co.uk/email/smtp.html

06 August 2015

smtplib handle non-ascii

email_body_msg = "victim’s reach"

char between m and s is non ascii character.

smtplib (python) cannot handle this. So what is the solution?

Simple solution, Just convert all the email_body_msg to base64. 

1) Use another python lib:
     from email.mime.text import MIMEText

2) Use UTF-8
     message = MIMEText(email_body_msg, _charset="UTF-8")

3) convert MIMEText back to string
    smtplib.SMTP.sendmail(self.mfrom, receivers, message.as_string())

good read: