# Path: pyhaystack/util/state.py
# @property
# def state(self):
#     """
#     Return the current state machine's state.
#     """
#     return self._state_machine.current
# 
# Path: pyhaystack/util/asyncexc.py
# class AsynchronousException(object):
#     def __init__(self):
#         self._exc_info = exc_info()
# 
#     def reraise(self):
#         reraise(*self._exc_info)


import hszinc
import fysom
import pytz
from copy import deepcopy
from datetime import tzinfo
from six import string_types
from ...util import state
from ...util.asyncexc import AsynchronousException
    from pandas import Series, DataFrame
            # Write the data
            self._session.his_write(
                point=self._entity_id,
                timestamp_records=records,
                callback=self._on_write,
            )
        except:
            self._state_machine.exception(result=AsynchronousException())

    def _on_write(self, operation, **kwargs):
        """
        Handle the write error, if any.
        """
        try:
            # See if the write succeeded.
            grid = operation.result
            if not isinstance(grid, hszinc.Grid):
                raise TypeError("Unexpected result: %r" % grid)
            # Move to the done state.
            self._state_machine.write_done(result=None)
        except:  # Catch all exceptions to pass to caller.
            self._state_machine.exception(result=AsynchronousException())

    def _do_done(self, event):
        """
        Return the result from the state machine.
        """
        self._done(event.result)



# Path: pyhaystack/util/state.py
# @property
# def state(self):
#     """
#     Return the current state machine's state.
#     """
#     return self._state_machine.current
# 
# Path: pyhaystack/util/asyncexc.py
# class AsynchronousException(object):
#     def __init__(self):
#         self._exc_info = exc_info()
# 
#     def reraise(self):
#         reraise(*self._exc_info)


# Path: pyhaystack/client/ops/his.py
import hszinc
import fysom
import pytz
from copy import deepcopy
from datetime import tzinfo
from six import string_types
from ...util import state
from ...util.asyncexc import AsynchronousException
    from pandas import Series, DataFrame

            # Write the data
            self._session.his_write(
                point=self._entity_id,
                timestamp_records=records,
                callback=self._on_write,
            )
        except:
            self._state_machine.exception(result=AsynchronousException())

    def _on_write(self, operation, **kwargs):
        """
        Handle the write error, if any.
        """
        try:
            # See if the write succeeded.
            grid = operation.result
            if not isinstance(grid, hszinc.Grid):
                raise TypeError("Unexpected result: %r" % grid)
            # Move to the done state.
            self._state_machine.write_done(result=None)
        except:  # Catch all exceptions to pass to caller.
            self._state_machine.exception(result=AsynchronousException())

    def _do_done(self, event):
        """
        Return the result from the state machine.
        """
        self._done(event.result)



class HisWriteFrameOperation(state.HaystackOperation):