Commit c2ba471528e12fcb36bffe11756caac1e2f982c9

Authored by Miguel Barão
1 parent a1b9de76
Exists in master and in 1 other branch dev

start topic is now async. this is important because a set of questions is genera…

…ted at this point. maybe questions should be generated in parallel?
Showing 3 changed files with 10 additions and 4 deletions   Show diff stats
BUGS.md
1 1  
2 2 # BUGS
3 3  
  4 +- SQLAlchemy error (rollback em accao no final de um topico):
  5 + Users/mjsb/Library/Python/3.7/lib/python/site-packages/sqlalchemy/sql/crud.py:700: SAWarning: Column 'studenttopic.student_id' is marked as a member of the primary key for table 'studenttopic', but has no Python-side or server-side default generator indicated, nor does it indicate 'autoincrement=True' or 'nullable=True', and no explicit value is passed. Primary key columns typically may not store NULL. Note that as of SQLAlchemy 1.1, 'autoincrement=True' must be indicated explicitly for composite (e.g. multicolumn) primary keys if AUTO_INCREMENT/SERIAL/IDENTITY behavior is expected for one of the columns in the primary key. CREATE TABLE statements are impacted by this change as well on most backends.
  6 + util.warn(msg)
  7 +
4 8 - quando a pergunta devolve comments, este é apresentado, mas fica persistente nas tentativas seguintes. devia ser limpo apos a segunda submissao.
5 9 - a opcao max_tries na especificacao das perguntas é cumbersome... usar antes tries?
6 10 - tabelas nas perguntas radio/checkbox não ocupam todo o espaço como em question.
... ...
learnapp.py
... ... @@ -195,9 +195,11 @@ class LearnApp(object):
195 195 # ------------------------------------------------------------------------
196 196 # Start new topic
197 197 # ------------------------------------------------------------------------
198   - def start_topic(self, uid, topic):
  198 + async def start_topic(self, uid, topic):
  199 + loop = asyncio.get_running_loop()
199 200 try:
200   - self.online[uid]['state'].init_topic(topic)
  201 + await loop.run_in_executor(None, self.online[uid]['state'].init_topic, topic)
  202 + # self.online[uid]['state'].init_topic(topic)
201 203 except KeyError as e:
202 204 logger.warning(f'User "{uid}" tried to open nonexistent topic: "{topic}"')
203 205 raise e
... ...
serve.py
... ... @@ -146,11 +146,11 @@ class RootHandler(BaseHandler):
146 146 # ----------------------------------------------------------------------------
147 147 class TopicHandler(BaseHandler):
148 148 @tornado.web.authenticated
149   - def get(self, topic):
  149 + async def get(self, topic):
150 150 uid = self.current_user
151 151  
152 152 try:
153   - self.learn.start_topic(uid, topic)
  153 + await self.learn.start_topic(uid, topic)
154 154 except KeyError:
155 155 self.redirect('/')
156 156 else:
... ...