def _no_primary(max_staleness, selection):
 smax = selection.secondary_with_max_last_write_date()
 if (not smax):
  return selection.with_server_descriptions([])
 sds = []
 for s in selection.server_descriptions:
  if (s.server_type == SERVER_TYPE.RSSecondary):
   staleness = ((smax.last_write_date - s.last_write_date) + selection.heartbeat_frequency)
   if (staleness <= max_staleness):
    sds.append(s)
  else:
   sds.append(s)
 return selection.with_server_descriptions(sds)

def _no_primary ( max_staleness , selection ) : smax = selection . secondary_with_max_last_write_date ( ) if ( not smax ) : return selection . with_server_descriptions ( [ ] ) sds = [ ] for s in selection . server_descriptions : if ( s . server_type == SERVER_TYPE . RSSecondary ) : staleness = ( ( smax . last_write_date - s . last_write_date ) + selection . heartbeat_frequency ) if ( staleness <= max_staleness ) : sds . append ( s ) else : sds . append ( s ) return selection . with_server_descriptions ( sds )
apply max_staleness .