A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/commit/19e9fefc660d623ce7c31fb008cde1157ae12aba below:

return None on connect() in case of EWOULDBLOCK/ECONN… · python/cpython@19e9fef · GitHub

35 35

and if remoteport is not given, then 25 is used.

36 36

"""

37 37 38 - 39 38

# Overview:

40 39

#

41 40

# This file implements the minimal SMTP protocol as defined in RFC 821. It

@@ -96,15 +95,13 @@ def flush(self): pass

96 95

COMMASPACE = ', '

97 96 98 97 99 - 100 98

def usage(code, msg=''):

101 99

print >> sys.stderr, __doc__ % globals()

102 100

if msg:

103 101

print >> sys.stderr, msg

104 102

sys.exit(code)

105 103 106 104 107 - 108 105

class SMTPChannel(asynchat.async_chat):

109 106

COMMAND = 0

110 107

DATA = 1

@@ -276,7 +273,6 @@ def smtp_DATA(self, arg):

276 273

self.push('354 End data with <CR><LF>.<CR><LF>')

277 274 278 275 279 - 280 276

class SMTPServer(asyncore.dispatcher):

281 277

def __init__(self, localaddr, remoteaddr):

282 278

self._localaddr = localaddr

@@ -299,22 +295,11 @@ def __init__(self, localaddr, remoteaddr):

299 295

localaddr, remoteaddr)

300 296 301 297

def handle_accept(self):

302 -

try:

303 -

conn, addr = self.accept()

304 -

except TypeError:

305 -

# sometimes accept() might return None

306 -

return

307 -

except socket.error, err:

308 -

# ECONNABORTED might be thrown

309 -

if err[0] != errno.ECONNABORTED:

310 -

raise

311 -

return

312 -

else:

313 -

# sometimes addr == None instead of (ip, port)

314 -

if addr == None:

315 -

return

316 -

print >> DEBUGSTREAM, 'Incoming connection from %s' % repr(addr)

317 -

channel = SMTPChannel(self, conn, addr)

298 +

pair = self.accept()

299 +

if pair is not None:

300 +

conn, addr = pair

301 +

print >> DEBUGSTREAM, 'Incoming connection from %s' % repr(addr)

302 +

channel = SMTPChannel(self, conn, addr)

318 303 319 304

# API for "doing something useful with the message"

320 305

def process_message(self, peer, mailfrom, rcpttos, data):

@@ -342,7 +327,6 @@ def process_message(self, peer, mailfrom, rcpttos, data):

342 327

raise NotImplementedError

343 328 344 329 345 - 346 330

class DebuggingServer(SMTPServer):

347 331

# Do something with the gathered message

348 332

def process_message(self, peer, mailfrom, rcpttos, data):

@@ -358,7 +342,6 @@ def process_message(self, peer, mailfrom, rcpttos, data):

358 342

print '------------ END MESSAGE ------------'

359 343 360 344 361 - 362 345

class PureProxy(SMTPServer):

363 346

def process_message(self, peer, mailfrom, rcpttos, data):

364 347

lines = data.split('\n')

@@ -399,7 +382,6 @@ def _deliver(self, mailfrom, rcpttos, data):

399 382

return refused

400 383 401 384 402 - 403 385

class MailmanProxy(PureProxy):

404 386

def process_message(self, peer, mailfrom, rcpttos, data):

405 387

from cStringIO import StringIO

@@ -478,13 +460,11 @@ def process_message(self, peer, mailfrom, rcpttos, data):

478 460

msg.Enqueue(mlist, torequest=1)

479 461 480 462 481 - 482 463

class Options:

483 464

setuid = 1

484 465

classname = 'PureProxy'

485 466 486 467 487 - 488 468

def parseargs():

489 469

global DEBUGSTREAM

490 470

try:

@@ -541,7 +521,6 @@ def parseargs():

541 521

return options

542 522 543 523 544 - 545 524

if __name__ == '__main__':

546 525

options = parseargs()

547 526

# Become nobody


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4