<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def query_proc(procname, args=(), factory=None):
 """ Execute a stored procedure. This returns an iterator of the result set. """

    ctx = Context.current()
    factory = ctx.default_factory if factory is None else factory
    with ctx.mdr:
        return factory(ctx.execute_proc(procname, args), ctx.mdr)