Skip to content

Commit

Permalink
Check h2 connection state
Browse files Browse the repository at this point in the history
Fixes "Invalid input ConnectionInputs.SEND_HEADERS in state
ConnectionState.CLOSED"
  • Loading branch information
etataurov committed Apr 18, 2016
1 parent 8436097 commit bde3fba
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions asyncio_apns/h2_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json
from urllib.parse import urlsplit

from h2.connection import H2Connection
from h2.connection import H2Connection, ConnectionState
from h2.events import (ConnectionTerminated, DataReceived,
ResponseReceived, StreamEnded)

Expand Down Expand Up @@ -46,7 +46,10 @@ def __init__(self, connection=H2Connection()):

@property
def connected(self):
return self.transport is not None
return self.transport is not None and not self.connection_closed()

def connection_closed(self):
return self.conn.state_machine.state == ConnectionState.CLOSED

@classmethod
@asyncio.coroutine
Expand Down

0 comments on commit bde3fba

Please sign in to comment.